import
java.util.*;
class
GFG{
static
int
checkQwertyRow(
char
x)
{
Character[] first_row1 = {
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'0'
,
'-'
,
'='
};
Set<Character> first_row =
new
HashSet<>(
Arrays.asList(first_row1));
Character[] second_row1 = {
'Q'
,
'W'
,
'E'
,
'R'
,
'T'
,
'Y'
,
'U'
,
'I'
,
'O'
,
'P'
,
'['
,
']'
,
'q'
,
'w'
,
'e'
,
'r'
,
't'
,
'y'
,
'u'
,
'i'
,
'o'
,
'p'
};
Set<Character> second_row =
new
HashSet<>(
Arrays.asList(second_row1));
Character[] third_row1 = {
'A'
,
'S'
,
'D'
,
'F'
,
'G'
,
'H'
,
'J'
,
'K'
,
'L'
,
';'
,
':'
,
'a'
,
's'
,
'd'
,
'f'
,
'g'
,
'h'
,
'j'
,
'k'
,
'l'
};
Set<Character> third_row =
new
HashSet<>(
Arrays.asList(third_row1));
Character[] fourth_row1 = {
'Z'
,
'X'
,
'C'
,
'V'
,
'B'
,
'N'
,
'M'
,
','
,
'.'
,
'/'
,
'z'
,
'x'
,
'c'
,
'v'
,
'b'
,
'n'
,
'm'
};
Set<Character> fourth_row =
new
HashSet<>(
Arrays.asList(fourth_row1));
if
(first_row.contains(x))
{
return
1
;
}
else
if
(second_row.contains(x))
{
return
2
;
}
else
if
(third_row.contains(x))
{
return
3
;
}
else
if
(fourth_row.contains(x))
{
return
4
;
}
return
0
;
}
static
boolean
checkValidity(String str)
{
char
x = str.charAt(
0
);
int
row = checkQwertyRow(x);
for
(
int
i =
0
; i < str.length(); i++)
{
x = str.charAt(i);
if
(row != checkQwertyRow(x))
{
return
false
;
}
}
return
true
;
}
public
static
void
main(String[] args)
{
String str =
"GeeksforGeeks"
;
if
(checkValidity(str))
System.out.println(
"Yes"
);
else
System.out.println(
"No"
);
}
}