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:
// package eround101;

import java.util.*;
import java.io.*;
import java.lang.*;
import java.util.StringTokenizer;
import java.util.concurrent.TimeUnit;

public class C101 {

    static HritikScanner sc = new HritikScanner();
    static PrintWriter pw = new PrintWriter(System.out, true);
    final static int MOD = (int) 1e9 + 7;
    static StringBuilder sb = new StringBuilder();

    public static void main(String[] args) {

        int t = ni();
        while (t-- > 0) {
            solve();
        }
    }

     static void solve() {
        //int n = ni();
        
        String str = sc.next();
        int n = str.length();
        for(int i = 1; i< n; i++)
        {
            if(str.charAt(i) == '1' && str.charAt(i-1) == '1')
            {
                for(int j = i+2; j < n; j++)
                {
                    if(str.charAt(j) == '0' && str.charAt(j-1) == '0')
                    {
                        pl("NO");
                        return;
                        
                    }
                }
            }
        }
        pl("yes");
        
    }
    
    
    /////////////////////////////////////////////////////////////////////////////////
    static int[] nextIntArray(int n) {
        int[] arr = new int[n];
        int i = 0;
        while (i < n) {
            arr[i++] = ni();
        }
        return arr;
    }

    static long[] nextLongArray(int n) {
        long[] arr = new long[n];
        int i = 0;
        while (i < n) {
            arr[i++] = nl();
        }
        return arr;
    }

    static int[] nextIntArray1(int n) {
        int[] arr = new int[n + 1];
        int i = 1;
        while (i <= n) {
            arr[i++] = ni();
        }
        return arr;
    }

    /////////////////////////////////////////////////////////////////////////////////
    static int ni() {
        return sc.nextInt();
    }

    static long nl() {
        return sc.nextLong();
    }

    static double nd() {
        return sc.nextDouble();
    }

    /////////////////////////////////////////////////////////////////////////////////
    static void pl() {
        pw.println();
    }

    static void p(Object o) {
        pw.print(o+ " ");
    }

    static void pl(Object o) {
        pw.println(o);
    }

    static void psb(StringBuilder sb) {
        pw.print(sb);
    }

    static void pa(Object arr[]) {
        for (Object o : arr) {
            p(o);
        }
        pl();
    }

    static void pa(int arr[]) {
        for (int o : arr) {
            p(o);
        }
        pl();
    }

    static void pa(long arr[]) {
        for (long o : arr) {
            p(o);
        }
        pl();
    }

    static void pa(double arr[]) {
        for (double o : arr) {
            p(o);
        }
        pl();
    }

    static void pa(char arr[]) {
        for (char o : arr) {
            p(o);
        }
        pl();
    }

    static void pa(List list) {
        for (Object o : list) {
            p(o);
        }
        pl();
    }

    static void pa(Object[][] arr) {

        for (int i = 0; i < arr.length; ++i) {
            for (Object o : arr[i]) {
                p(o);
            }
            pl();
        }
    }

    static void pa(int[][] arr) {
        for (int i = 0; i < arr.length; ++i) {
            for (int o : arr[i]) {
                p(o);
            }
            pl();
        }
    }

    static void pa(long[][] arr) {
        for (int i = 0; i < arr.length; ++i) {
            for (long o : arr[i]) {
                p(o);
            }
            pl();
        }
    }

    static void pa(char[][] arr) {
        for (int i = 0; i < arr.length; ++i) {
            for (char o : arr[i]) {
                p(o);
            }
            pl();
        }
    }

    static void pa(double[][] arr) {
        for (int i = 0; i < arr.length; ++i) {
            for (double o : arr[i]) {
                p(o);
            }
            pl();
        }
    }

/////////////////////////////////////////////////////////////////////////////////
    static void print(Object s) {
        System.out.println(s);
    }

    /////////////////////////////////////////////////////////////////////////////////
    //-----------HritikScanner class for faster input----------//
    static class HritikScanner {

        BufferedReader br;
        StringTokenizer st;

        public HritikScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    //////////////////////////////////////////////////////////////////
    public static class Pair implements Comparable<Pair> {

        int num, row,col;

        Pair(int num, int row, int col) {
            this.num = num;
            this.row = row;
            this.col = col;
        }

        public int get1() {
            return num;
        }

        public int get2() {
            return row;
        }

        public int compareTo(Pair A) {
            return this.num - A.num;
        }
        
        public String toString()
        {
            return num +" "+ row+" "+col;
        }
    }

    //////////////////////////////////////////////////////////////////
    // Function to return gcd of a and b time complexity O(log(a+b))
    static long gcd(long a, long b) {
        if (a == 0) {
            return b;
        }
        return gcd(b % a, a);
    }

    // method to return LCM of two numbers 
    static long lcm(int a, int b) {
        return (a / gcd(a, b)) * b;
    }

    //////////////////////////////////////////////////////////////////
    static boolean isPrime(long n) {
        // Corner cases 
        if (n <= 1) {
            return false;
        }
        if (n <= 3) {
            return true;
        }

        // This is checked so that we can skip  
        // middle five numbers in below loop 
        if (n % 2 == 0 || n % 3 == 0) {
            return false;
        }

        for (long i = 5; i * i <= n; i = i + 6) {
            if (n % i == 0 || n % (i + 2) == 0) {
                return false;
            }
        }

        return true;
    }
    //////////////////////////////////////////////////////////////////

    static boolean isPowerOfTwo(long n) {
        if (n == 0) {
            return false;
        }

        return (long) (Math.ceil((Math.log(n) / Math.log(2))))
                == (long) (Math.floor(((Math.log(n) / Math.log(2)))));
    }

    public static long getFact(int n) {
        long ans = 1;
        while (n > 0) {
            ans *= n;
            ans %= MOD;
            n--;
        }
        return ans;
    }

    public static long pow(long n, int pow) {
        if (pow == 0) {
            return 1;
        }
        long temp = pow(n, pow / 2) % MOD;
        temp *= temp;
        temp %= MOD;
        if (pow % 2 == 1) {
            temp *= n;
        }
        temp %= MOD;
        return temp;

    }

    public static long nCr(int n, int r) {
        long ans = 1;
        int temp = n - r;
        while (n > temp) {
            ans *= n;
            ans %= MOD;
            n--;
        }
        ans *= pow(getFact(r) % MOD, MOD - 2) % MOD;
        ans %= MOD;
        return ans;
    }

    //////////////////////////////////////////////////////////////////
    // method returns Nth power of A 
    static double nthRoot(int A, int N) {

        // intially guessing a random number between 
        // 0 and 9 
        double xPre = Math.random() % 10;

        // smaller eps, denotes more accuracy 
        double eps = 0.001;

        // initializing difference between two 
        // roots by INT_MAX 
        double delX = 2147483647;

        // xK denotes current value of x 
        double xK = 0.0;

        // loop untill we reach desired accuracy 
        while (delX > eps) {
            // calculating current value from previous 
            // value by newton's method 
            xK = ((N - 1.0) * xPre
                    + (double) A / Math.pow(xPre, N - 1)) / (double) N;
            delX = Math.abs(xK - xPre);
            xPre = xK;
        }

        return xK;
    }

}