import java.io.*; import java.util.Collections; import java.util.Set; import java.util.TreeSet; /** * Created by pdhinwa on 14/08/2016 AD. */ public class Main { void main() throws IOException { Reader reader = new Reader(); Writer writer = new Writer(); int T = reader.readInt(); Checker.check(T, 1, 200); while (T-- > 0) { String[] a = reader.readString().split(" "); checkValidity(a); String[] b = reader.readString().split(" "); checkValidity(b); int common = 0; for (String s: a) { boolean ok = false; for (String t: b) { if (s.compareTo(t) == 0) { ok = true; } } if (ok) { common++; } } writer.println(common >= 2 ? "similar" : "dissimilar"); } writer.close(); reader.readEof(); } private void checkValidity(String[] a) { Checker.check(a.length == 4); Set set = new TreeSet(); Collections.addAll(set, a); Checker.check(set.size() == 4); for (String s: a) { Checker.check(s.length(), 2, 10); for (int i = 0; i < s.length(); i++) { Checker.check(s.charAt(i), 'a', 'z'); } } } public static void main(String[] args) throws IOException { try { new Main().main(); } catch (Exception e) { e.printStackTrace(); throw e; } } private class Writer extends PrintWriter { Writer() throws FileNotFoundException { super(System.out); } Writer(File file) throws FileNotFoundException { super(file); } } private class Reader { String[] data; BufferedReader bufferedReader; Reader() { bufferedReader = new BufferedReader(new InputStreamReader(System.in)); } Reader(File file) throws FileNotFoundException { bufferedReader = new BufferedReader(new FileReader(file)); } String readString() throws IOException { return bufferedReader.readLine(); } void readEof() throws IOException { Checker.check(readString() == null); } int readInt() throws IOException { return Integer.parseInt(readString()); } int[] readArray() throws IOException { data = readString().split(" "); int[] res = new int[data.length]; for (int i = 0; i < res.length; i++) { res[i] = Integer.parseInt(data[i]); } return res; } } private static class Checker { private static void check(long x, long L, long R) { if (x < L || x > R) { throw new RuntimeException(); } } private static void check(boolean b) { if (!b) { throw new RuntimeException(); } } private static void check(int x, int L, int R) { if (x < L || x > R) { throw new RuntimeException(); } } } }