import
java.util.*;
class
GFG
{
static
int
nx =
0
, ny =
0
;
static
boolean
check(String s,
int
p,
int
q)
{
for
(
int
i =
0
; i < s.length(); ++i)
{
if
(s.charAt(i) ==
'x'
)
nx++;
else
ny++;
}
if
((nx * ny) != (p + q))
return
true
;
else
return
false
;
}
public
static
String smallestPermutation(String s,
int
p,
int
q)
{
if
(check(s, p, q) ==
true
)
{
return
"Impossible"
;
}
char
tempArray[] = s.toCharArray();
Arrays.sort(tempArray);
String str =
new
String(tempArray);
int
a = nx * ny, b =
0
, i =
0
, j =
0
;
if
(a == p && b == q)
{
return
str;
}
while
(
1
>
0
)
{
for
(i =
0
; i < str.length() -
1
; ++i)
{
if
(str.charAt(i) ==
'x'
&&
str.charAt(i +
1
) ==
'y'
)
break
;
}
for
(j = i; j < str.length() -
1
; j++)
{
if
(str.charAt(j) ==
'x'
&&
str.charAt(j +
1
) ==
'y'
)
{
StringBuilder sb =
new
StringBuilder(str);
sb.setCharAt(j, str.charAt(j +
1
));
sb.setCharAt(j +
1
, str.charAt(j));
str = sb.toString();
a--;
b++;
if
(a == p && b == q)
{
return
str;
}
}
}
}
}
public
static
void
main (String[] args)
{
String s =
"yxxyx"
;
int
p =
3
, q =
3
;
System.out.print(smallestPermutation(s, p, q));
}
}