package com.bmw.sequencecatalogue; import java.util.*; // IT IS IMPORTANT THAT YOUR CLASS HAS THE NAME PROG! class prog { public static void main(String[] args) throws java.lang.Exception { Scanner scanner = new Scanner(System.in); //String vocale = "aeiou"; int t = Integer.parseInt(scanner.next().trim()); for (int i = 0; i < t; i++) { String s = scanner.next(); if (s.charAt(3) == '0' && s.charAt(4) == '0') System.out.println("YES"); else if (s.charAt(0) == s.charAt(3) && s.charAt(1) == s.charAt(4)) System.out.println("YES"); else if (s.charAt(0) == s.charAt(4) && s.charAt(1) == s.charAt(3)) System.out.println("YES"); else if (s.charAt(0) == s.charAt(4) && s.charAt(1) == s.charAt(3)) System.out.println("YES"); else if (s.charAt(0) == '0' && s.charAt(1) == '1' && s.charAt(3) == '2' && s.charAt(4) == '3') System.out.println("YES"); else if (s.charAt(0) == '1' && s.charAt(1) == '2' && s.charAt(3) == '3' && s.charAt(4) == '4') System.out.println("YES"); else if (s.charAt(0) == '1' && s.charAt(1) == '0' && s.charAt(3) == '2' && s.charAt(4) == '4') System.out.println("YES"); else if (s.charAt(0) == '2' && s.charAt(1) == '0' && s.charAt(3) == '4' && s.charAt(4) == '8') System.out.println("YES"); else System.out.println("NO"); } //System.out.println(a + b); } }