Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class ccc04s1
- {
- public static void main (String[] args)
- {
- Scanner str = new Scanner(System.in);
- int counter = Integer.parseInt(str.next());
- for (int i = 0; i <= counter; i++)
- {
- String [] words = new String [3];
- for (int j = 0; j <=2; j++)
- {
- words [j] = str.nextLine();
- }
- char pretemp = words[0].charAt(0);
- char suftemp = words[0].charAt(words[0].length()-1);
- String pre = Character.toString(pretemp);
- String suf = Character.toString(suftemp);
- if ((words[1].startsWith(pre) && words[2].startsWith(pre)) || (words[1].endsWith(suf)|| words[2].endsWith(suf)))
- {
- System.out.println("No");
- }
- else
- System.out.println("Yes");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement