import
java.util.HashSet;
class
GFG
{
static
HashSet<String> stringSet =
new
HashSet<>();
public
static
void
find_permutation(String str1, String str2,
int
len1,
int
len2,
int
i,
int
j, String res)
{
if
(res.length() == len1 + len2)
{
stringSet.add(res);
return
;
}
if
(i < len1)
find_permutation(str1, str2, len1, len2, i +
1
,
j, res + str1.charAt(i));
if
(j < len2)
find_permutation(str1, str2, len1, len2, i, j +
1
,
res + str2.charAt(j));
}
public
static
void
print_set()
{
for
(String s : stringSet)
System.out.println(s);
}
public
static
void
main(String[] args)
{
String str1 =
"aa"
, str2 =
"ab"
;
int
len1 = str1.length();
int
len2 = str2.length();
find_permutation(str1, str2, len1, len2,
0
,
0
,
""
);
print_set();
}
}