import
java.util.*;
class
GFG
{
static
int
[]parent =
new
int
[
26
];
static
int
find(
int
x)
{
if
(x != parent[x])
return
parent[x] = find(parent[x]);
return
x;
}
static
void
join(
int
x,
int
y)
{
int
px = find(x);
int
pz = find(y);
if
(px != pz)
{
parent[pz] = px;
}
}
static
boolean
convertible(String s1, String s2)
{
HashMap<Integer,Integer> mp =
new
HashMap<Integer,Integer>();
for
(
int
i =
0
; i < s1.length(); i++)
{
if
(!mp.containsKey(s1.charAt(i) -
'a'
))
{
mp.put(s1.charAt(i) -
'a'
, s2.charAt(i) -
'a'
);
}
else
{
if
(mp.get(s1.charAt(i) -
'a'
) != s2.charAt(i) -
'a'
)
return
false
;
}
}
for
(Map.Entry<Integer, Integer> it : mp.entrySet())
{
if
(it.getKey() == it.getValue())
continue
;
else
{
if
(find(it.getKey()) == find(it.getValue()))
return
false
;
else
join(it.getKey(), it.getValue());
}
}
return
true
;
}
static
void
initialize()
{
for
(
int
i =
0
; i <
26
; i++)
{
parent[i] = i;
}
}
public
static
void
main(String[] args)
{
String s1, s2;
s1 =
"abbcaa"
;
s2 =
"bccdbb"
;
initialize();
if
(convertible(s1, s2))
System.out.print(
"Yes"
+
"\n"
);
else
System.out.print(
"No"
+
"\n"
);
}
}