Problem: You are given a string s, consisting only of characters '0' or '1'. Let |s| be the length of s.

You are asked to choose some integer k (k > 0) and find a sequence a of length k such that: 

  * 1 ≤ a_1 < a_2 < ... < a_k ≤ |s|; 
  * a_{i-1} + 1 < a_i for all i from 2 to k. 



The characters at positions a_1, a_2, ..., a_k are removed, the remaining characters are concatenated without changing the order. So, in other words, the positions in the sequence a should not be adjacent.

Let the resulting string be s'. s' is called sorted if for all i from 2 to |s'| s'_{i-1} ≤ s'_i.

Does there exist such a sequence a that the resulting string s' is sorted?

Input

The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of testcases.

Then the descriptions of t testcases follow.

The only line of each testcase contains a string s (2 ≤ |s| ≤ 100). Each character is either '0' or '1'.

Output

For each testcase print "YES" if there exists a sequence a such that removing the characters at positions a_1, a_2, ..., a_k and concatenating the parts without changing the order produces a sorted string.

Otherwise, print "NO".

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).

Example

Input


5
10101011011
0000
11111
110
1100


Output


YES
YES
YES
YES
NO

Note

In the first testcase you can choose a sequence a=[1,3,6,9]. Removing the underlined letters from "10101011011" will produce a string "0011111", which is sorted.

In the second and the third testcases the sequences are already sorted.

In the fourth testcase you can choose a sequence a=[3]. s'= "11", which is sorted.

In the fifth testcase there is no way to choose a sequence a such that s' is sorted.

Solution (in JAVA):

Solution:
import java.util.*;

public class CF102 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            String s = sc.next();
           /* StringBuilder adj1= new StringBuilder();
            StringBuilder adj2= new StringBuilder();*/
            if(s.contains("1100")){
                System.out.println("NO");
            }else {
                if(s.length()>2){
                    char st1=s.charAt(0);
                    char st2=s.charAt(1);

                    if(st1=='0' && st2=='0'){
                        int ind1=s.indexOf("11");
                        int ind2=s.lastIndexOf("00");
                        if(ind1!=-1&&ind1<ind2){
                            System.out.println("NO");
                        }else {
                            System.out.println("YES");
                        }

                    }else if(st1=='1' && st2=='1'){
                        String f=s.substring(2);
                        if(f.contains("00")){
                            System.out.println("NO");
                        }else {
                            System.out.println("YES");
                        }
                    }else if(st1=='0' && st2=='1'){
                         boolean case1=true;
                         boolean case2=true;
                         String f=s.substring(2);
                        if(f.contains("00")){
                          //  System.out.println("NO");
                            case1=false;
                        }/*else {
                            System.out.println("YES");
                        }*/
                        int ind1=s.indexOf("11");
                        int ind2=s.lastIndexOf("00");
                        if(ind1!=-1&&ind1<ind2){
                           // System.out.println("NO");
                            case2=false;
                        }/*else {
                            System.out.println("YES");
                        }*/
                        if(case1||case2){
                            System.out.println("YES");
                        }else {
                            System.out.println("NO");
                        }
                    }else if(st1=='1' && st2=='0'){
                        int ind1=s.indexOf("11");
                        int ind2=s.lastIndexOf("00");
                        if(ind1!=-1&&ind1<ind2){
                            System.out.println("NO");
                        }else {
                            System.out.println("YES");
                        }
                    }
                }else {
                    System.out.println("YES");
                }
               /* for(int j=0;j<s.length();j++){
                    if(j%2==0){
                        adj1.append(s.charAt(j));
                    }else {
                        adj2.append(s.charAt(j));
                    }
                }
                boolean check1=true;
                boolean check2=true;
                if(adj1.toString().contains("10")){
                    check1=false;
                }
                if(adj2.toString().contains("10")){
                    check2=false;
                }
                if(check1 || check2){
                    System.out.println("YES");
                }else {
                    System.out.println("NO");
                }
               // System.out.println("YES");*/
            }

        }


    }

    public static void minDfs(boolean[] visited, int num, List<List<Integer>> lists) {
        visited[num] = true;
        // min=Math.min(min,price[num]);
        for (Integer integer : lists.get(num)) {
            if (!visited[integer])
                minDfs(visited, integer, lists);
        }
        //return min;

    }


    public static long power(long a, long b, long c) {
        long ans = 1;
        while (b != 0) {
            if (b % 2 == 1) {
                ans = ans * a;
                ans %= c;
            }
            a = a * a;
            a %= c;
            b /= 2;
        }
        return ans;
    }

    public static long power1(long a, long b, long c) {
        long ans = 1;
        while (b != 0) {
            if (b % 2 == 1) {
                ans = multiply(ans, a, c);
            }
            a = multiply(a, a, c);
            b /= 2;

        }
        return ans;

    }

    public static long multiply(long a, long b, long c) {
        long res = 0;
        a %= c;
        while (b > 0) {
            if (b % 2 == 1) {
                res = (res + a) % c;
            }
            a = (a + a) % c;
            b /= 2;
        }

        return res % c;

    }

    public static long totient(long n) {
        long result = n;
        for (long i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                //sum=sum+2*i;
                while (n % i == 0) {
                    n /= i;
                    // sum=sum+n;
                }
                result -= result / i;

            }
        }
        if (n > 1) {
            result -= result / n;

        }
        return result;
    }


    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    public static boolean[] primes(int n) {
        boolean[] p = new boolean[n + 1];
        p[0] = false;
        p[1] = false;
        for (int i = 2; i <= n; i++) {
            p[i] = true;
        }

        for (int i = 2; i * i <= n; i++) {
            if (p[i]) {
                for (int j = i * i; j <= n; j += i) {
                    p[j] = false;
                }
            }

        }
        return p;
    }

    public int minimumLength(String s) {
        String s1 = "";
        for (int i = 0; i < s.length() - 1; i++) {
            char ch = s.charAt(i);
            char ch1 = s.charAt(i + 1);
            if (ch != ch1) {
                s1 = s1 + ch;

            }


        }
        s1 = s1 + s.charAt(s.length() - 1);
        String[] ar = s1.split("");
        for (int i = 0; i < s1.length() - 1; i++) {
            if (i <= s1.length() - 1 - i) {
                char ch1 = ar[i].charAt(0);
                char ch2 = ar[s1.length() - 1 - i].charAt(0);
                if (ch1 != ch2) {
                    break;
                } else {
                    ar[i] = "";
                    ar[s1.length() - 1 - i] = "";
                }
            } else {
                break;
            }

        }

        String s2 = "";
        for (String s3 : ar) {
            s2 = s2 + s3;
        }

        return s2.length();


    }

    public static long[] totientfrom1ton(long n) {
        long[] totient = new long[(int) (n + 1)];
        totient[0] = 0;
        totient[1] = 1;
        for (int i = 2; i <= n; i++) {
            totient[i] = i;
        }
        for (int i = 2; i <= n; i++) {
            if (totient[i] == i) {
                totient[i] -= 1;
                for (int j = 2 * i; j <= n; j += i) {
                    totient[j] -= totient[j] / i;
                }
            }
        }
        return totient;

    }

    static long[] LcmSum(int n, long[] phi) {
        //ETF();
        long[] ans = new long[n + 1];

        for (int i = 1; i <= n; i++) {

            // Summation of d * ETF(d) where
            // d belongs to set of divisors of n
            for (int j = i; j <= n; j += i) {
                ans[j] += (i * phi[i]);
            }
        }

        for (int i = 1; i <= n; i++) {
            ans[i] = ((ans[i] + 1) * i) / 2;
        }

        /*int answer = ans[m];
        answer = (answer + 1) * m;
        answer = answer / 2;*/
        return ans;
    }

    static int hackerlandRadioTransmitters(int[] x, int k) {
        Arrays.sort(x);
        int c = 0;
        int lol = 0;
        process:
        while (lol <= (x.length - 1)) {


            int initial = x[lol];
            int nextno = initial + 2 * k;
            int low = lol + 1;
            int high = x.length - 1;
            int ans = -1;
            while (low <= high) {
                int mid = low + (high - low) / 2;
                if (x[mid] <= nextno) {
                    ans = mid;
                    low = mid + 1;
                } else {
                    high = mid - 1;
                }
            }
            if (ans != -1) {
                c++;
            }
            System.out.println(ans + " " + lol);
            lol = ans + 1;
        }
        return c;


    }
}