process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(str => str.trim());

    main();
});

function readLine() {
    return inputString[currentLine++];
}
function main()
{
    //const name=readLine();
    //console.log(name);

    let test=readLine();
    while(test--)
    {
        let str=readLine();
        let l=str.length;
        let val=97+l-1;
        //console.log(val);
        let pos_f=0,pos_b=l-1;
        let cnt=0;
        while(cnt<l)
        {
            let val_f=str.charCodeAt(pos_f);
            let val_b=str.charCodeAt(pos_b);
            if(val_f===val)
            {
                pos_f++;
                val--;
                cnt++;
            }
            else if(val_b===val)
            {
                val--;
                cnt++;
                pos_b--;
            }
            else
                break;
            }
            if(cnt===l)
            {
                console.log("YES");
            }
            else
            {
                console.log("NO");
            }

    }
}

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

process.stdin.on('data' , data=>{
    input += data;
});
process.stdin.on('end' , ()=>{
    main(input);
});

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        let str = input[z++].trim();
        let length = str.length;
        let asciiValues = str.split('').map(x=>x.charCodeAt(0) - 96);

        for (let i = length; i > 0; i--) {
            if(asciiValues[0] === i){
                asciiValues.shift();
            }
            else if(asciiValues[i - 1] === i){
                asciiValues.pop();
            }
        }
        asciiValues.length === 0 ? console.log("YES") : console.log('NO');
    }
}

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

process.stdin.on('data' , data=>{
    input += data;
});
process.stdin.on('end' , ()=>{
    main(input);
});

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        let str = input[z++].trim();
        let length = str.length;
        let acssiValue = str.split('').map(x=>x.charCodeAt(0) - 96);
        let sum = acssiValue.reduce((a,b)=>a+b);

        if(sum === (length * ((length + 1) / 2))){
            let flag = true;
            let ans = false;
            let index = acssiValue.indexOf(1);
            while (flag) {
                if(Math.abs(acssiValue[index] - acssiValue[index - 1]) == 1){
                    let abc = acssiValue.splice(index, 1);
                    index--;
                }
                else if(Math.abs(acssiValue[index] - acssiValue[index + 1]) == 1){
                    let abc = acssiValue.splice(index, 1);
                }
                else if(acssiValue.length === 1){
                    ans = true;
                    flag = false;
                }
                else{
                    flag = false;
                }
            }
            ans ? console.log('YES'): console.log("no");
        }
        else{
            console.log("NO");
        }
    }
}

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let s = nl.line();
		let x = s.indexOf('a');
		if (x == -1){
			ans.push(false);
		} else {
			let flag = true;
			let a = s.substring(0,x).split('');
			let b = s.substring(x).split('');
			let c = s.split('');
			c.sort((a, b) => a.charCodeAt(0) - b.charCodeAt(0));
			for(let j = 1; j < a.length && flag; j++){
				if (a[j-1] <= a[j]){
					flag = false;
				}
			}
			for(let j = 1; j < b.length && flag; j++){
				if (b[j-1] >= b[j]){
					flag = false;
				}

			}
			//console.log(c);
			for(let j = 1; j < c.length && flag; j++){
				if (c[j].charCodeAt(0) - c[j-1].charCodeAt(0) != 1){
					flag = false;
				}
			}
			ans.push(flag);
		}
	}
	console.log(ans.map(e => e?"YES":"NO").join('\n'));
};

process.stdin.on('end', sol);

let input = '';
process.stdin.on('data', (str) => input += str);
process.stdin.on('end', () => {
    const [n, ...lines] = input.trim().split('\n')
        .map(l => l.trim());

    for (let i=0; i<lines.length; i+=1) {
        console.log(solve(lines[i]))
    }
});

const solve = (string) => {
    try{
        if(string.length > 0){
            const largestAlpha = String.fromCharCode('a'.charCodeAt(0) + string.length - 1);

            if(string[0] === largestAlpha){
                return solve(string.slice(1))
            }else if(string[string.length - 1] === largestAlpha){
                return solve(string.slice(0, string.length - 1));
            }else {
                return 'NO'
            }
        }else {
            return 'YES'
        }
    }catch (ex){
        console.log('ex:', ex)
    }
}

var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

const getchar = n => String.fromCharCode('a'.charCodeAt(0) + n - 1);

function main () {
	let T = rn();
	while (T--) {
		const s = rl().split('');

		let n = s.length;
		while (n) {
			if (s[0] == getchar(n)) {
				s.shift();
			} else if (s[s.length-1] == getchar(n)) {
				s.pop();
			} else {
				break;
			}
			n--;
		}

		console.log(n == 0 ? 'YES' : 'NO');
	}
}

function isZero(num) {
   if (typeof num === 'bigint') {
      return num === 0n;
   }
   return num === 0;
}
function div(a, b) {
   if (typeof a !== typeof b) {
      throw new Error('Different types on division');
   }
   if (typeof a === 'bigint') {
      return a / b;
   }
   return Math.floor(a / b);
}

function gcd(x, y) {
   if (isZero(y)) {
      return x;
   }
   return gcd(y, x % y);
}

function lcm(x, y) {
   return div(x * y, gcd(x, y));
}

function allIndexOf(arr, value) {
   var index = arr.indexOf(value)
   var ans = [];
   while (index !== -1) {
      ans.push(index);
      index = arr.indexOf(value, index + 1);
   }
   return ans;
}

function xor(a, b, k) {
   if (k === 2) {
      return a ^ b;
   }
}

const acode = 'a'.charCodeAt(0);
const zcode = 'z'.charCodeAt(0);
const arr = [];
for (let i = acode; i <= zcode; i++) {
   arr.push(String.fromCharCode(i));
}

function solve() {
   const str = read();
   let l = str.indexOf('a');
   let r = l;
   if (l === -1) {
      write('NO');
      return;
   }
   for (let i = 1; i < arr.length; i++) {
      if (l === 0 && r === str.length - 1) {
         write('YES');
         return;
      }
      if (str[l - 1] === arr[i]) {
         l--;
         continue;
      }
      if (str[r + 1] === arr[i]) {
         r++;
         continue;
      }
      write('NO');
      return;
   }
   write(l === 0 && r === str.length - 1 ? 'YES' : 'NO');
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var l = 0;
    var t = +lines[l++]
    for (var i = 0; i < t; i++) {
        var str = lines[l++].trim()
        console.log(solve(str))
    }
});

function solve(str) {
    // console.log(str)
    let i = str.indexOf('a')
    if (i < 0) return 'NO'

    let l = i - 1
    let r = i + 1
    let expected = 'a'
    while (1) {
        expected = String.fromCharCode(expected.charCodeAt(0) + 1)
        if (l >= 0) {
            if (str[l] === expected) {
                l--
                continue
            }
        }
        if (r < str.length) {
            if (str[r] === expected) {
                r++
                continue
            }
        }
        break
    }
    return l < 0 && r >= str.length ? 'YES' : 'NO'
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = BigInt(next());
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var set = new Set();
	var alpha = "abcdefghijklmnopqrstuvwxyz";
	var t = nextInt();
	while(hasNext()){
		var s = nextCharArray();
		var used = new Set();
		var isOK = true;
		while(s.length > 0){
			if(s[0] == alpha[s.length - 1]){
				if(used.has(s[0])){
					isOK = false;
					break;
				}else{
					used.add(s[0]);
					s.shift();
				}
			}else if(s[s.length - 1] == alpha[s.length - 1]){
				if(used.has(s[s.length - 1])){
					isOK = false;
					break;
				}else{
					used.add(s[s.length - 1]);
					s.pop();
				}
			}else{
				isOK = false;
				break;
			}
		}
		if(isOK){
			myout("YES");
		}else{
			myout("NO");
		}
	}
}

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
// import * as readline from 'readline'
// const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
// const ask = (query: string) => new Promise<string>((resolve) => rl.question(query, resolve))
// // Don't forget `rl.close()`.
const INT = Math.floor;
Array.prototype.last = function () {
    return this.length === 0 ? undefined : this[this.length - 1];
};
Array.prototype.isEmpty = function () {
    return this.length === 0;
};
const less = (a, b) => (a == b ? 0 : a < b ? -1 : 1);
const greater = (a, b) => (a == b ? 0 : a < b ? 1 : -1);
const bigIntMax = (...args) => args.reduce((m, e) => (e > m ? e : m));
const bigIntMin = (...args) => args.reduce((m, e) => (e < m ? e : m));
const bigIntAbs = (arg) => (arg < 0 ? -arg : arg);
function read_stdin() {
    return fs.readFileSync(process.env.NODE_ENV === 'debug' ? stdin : process.stdin.fd, 'utf8');
}
class Input {
    constructor(str) {
        this.index = 0;
        this.inputs = (str ? str : read_stdin()).split(/\s+/);
    }
    number() {
        return Number(this.inputs[this.index++]);
    }
    numbers(n) {
        return this.inputs.slice(this.index, (this.index += n)).map(Number);
    }
    bigint() {
        return BigInt(this.inputs[this.index++]);
    }
    bigints(n) {
        return this.inputs.slice(this.index, (this.index += n)).map(BigInt);
    }
    word() {
        return this.inputs[this.index++];
    }
    words(n) {
        return this.inputs.slice(this.index, (this.index += n));
    }
}
function array(len, init) {
    return Array(len).fill(init);
}
function array2(h, w, init) {
    return array(h, 0).map(() => array(w, init));
}
function main() {
    const input = new Input();
    const t = input.number();
    const ans = Array(t);
    const base = 'a'.charCodeAt(0) - 1;
    loop: for (let i = 0; i < t; i++) {
        const s = input.word();
        const nums = Array.from(s).map((c) => c.charCodeAt(0) - base);
        // console.log(nums)
        for (let j = nums.length; j >= 1; j--) {
            if (nums[0] === j) {
                nums.shift();
            }
            else if (nums.last() === j) {
                nums.pop();
            }
            else {
                ans[i] = 'NO';
                continue loop;
            }
        }
        if (nums.isEmpty()) {
            ans[i] = 'YES';
        }
        else {
            ans[i] = 'NO';
        }
    }
    console.log(ans.join('\n'));
}
main();
//# sourceMappingURL=aoj.js.map

function main() {
  var isInclude = function(line,letter) {
    if (line.search(letter) === -1)
      return false
    else
      return true;
  }

  var getNextChar = function(string) {
    //base = "a".charCodeAt(0);
    return String.fromCharCode(string.length+"a".charCodeAt(0));
  }

  var isIncludeLetterRec = function(line, letter) {
    //print("isInclude> '"+line+"','"+letter+"'");
    if (line === letter) {
      //print("isIncludeLetterRec> string matched");
      return true;
    } else if (line.length == letter.length) {
      //print("isIncludeLetterRec> length over");
      return false;
    }
    if (isInclude(line,letter+getNextChar(letter))) {
      if (isIncludeLetterRec(line,letter+getNextChar(letter)))
        return true;
    } else if (isInclude(line,getNextChar(letter)+letter)) {
      if (isIncludeLetterRec(line,getNextChar(letter)+letter))
        return true;
    }
    //print("isIncludeLetterRec> no next char: '"+line+"','"+letter+"'");
    return false;
    //if (!isInclude(line,letter+getNextChar(letter)) &&
    //    !isInclude(line,getNextChar(letter)+letter)) {
    //  print("getIsAlphabetical> no next char");
    //  return false;
    //}
    //print("getIsAlphabetical> motto");
  }

  var getIsAlphabetical = function(line) {
    var letter = "a";
    if (!isInclude(line,letter)) {
      //print("getIsAlphabetical> no a");
      return false;
    }

    return isIncludeLetterRec(line, letter);
  }

  cntTestcase = parseInt(readline(),10);
  for (var i=0; i<cntTestcase; i++) {
    var isAlphabetical = getIsAlphabetical(readline());
    print(isAlphabetical?"YES":"NO");
  }
}

main();

var input = readline();
for(var i = 0; i < input; i ++) {
    var s = readline();
    var left = right = s.indexOf('a');
    var flag = 0;
    for(var j = 0; j < s.length; j ++) {
        var c = String.fromCharCode(j + 97);
        var ind = s.indexOf(c);
        if(ind === -1){
            flag = 1;
            print('NO');
            break;
        }
        if(j !== 0) {
            ind < left ? left = ind : (ind > right ? right = ind : flag = 1);
            if(flag){
                print('NO');
                break;
            }
        }
    }
    if(flag === 0) print('YES')
}

var x = parseInt(readline());
var input;

function charToInt(a) {
    if(a == 'a') return 1;
    else if(a == 'b') return 2;
    else if(a == 'c') return 3;
    else if(a == 'd') return 4;
    else if(a == 'e') return 5;
    else if(a == 'f') return 6;
    else if(a == 'g') return 7;
    else if(a == 'h') return 8;
    else if(a == 'i') return 9;
    else if(a == 'j') return 10;
    else if(a == 'k') return 11;
    else if(a == 'l') return 12;
    else if(a == 'm') return 13;
    else if(a == 'n') return 14;
    else if(a == 'o') return 15;
    else if(a == 'p') return 16;
    else if(a == 'q') return 17;
    else if(a == 'r') return 18;
    else if(a == 's') return 19;
    else if(a == 't') return 20;
    else if(a == 'u') return 21;
    else if(a == 'v') return 22;
    else if(a == 'w') return 23;
    else if(a == 'x') return 24;
    else if(a == 'y') return 25;
    else if(a == 'z') return 26;
    return 27;
}

for(i = 0; i < x; i++) {
input = readline();
var k = input.length;
for(j = 0; j < k; j++) {
    if(charToInt(input[0]) == input.length) input = input.slice(1, input.length);
    else if(charToInt(input[input.length - 1]) == input.length) input = input.slice(0, input.length - 1);
    else {
        print("NO");
        break;
    }
}
if(input.length == 0) print("YES");

}

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let s = nl.line();
		let x = s.indexOf('a');
		if (x == -1){
			ans.push(false);
		} else {
			let flag = true;
			let a = s.substring(0,x).split('');
			let b = s.substring(x).split('');
			let c = s.split('');
			c.sort((a, b) => a.charCodeAt(0) - b.charCodeAt(0));
			for(let j = 1; j < a.length && flag; j++){
				if (a[j-1] <= a[j]){
					flag = false;
				}
			}
			for(let j = 1; j < b.length && flag; j++){
				if (b[j-1] >= b[j]){
					flag = false;
				}

			}
			console.log(c);
			for(let j = 1; j < c.length && flag; j++){
				if (c[j].charCodeAt(0) - c[j-1].charCodeAt(0) != 1){
					flag = false;
				}
			}
			ans.push(flag);
		}
	}
	console.log(ans.map(e => e?"YES":"NO").join('\n'));
};

process.stdin.on('end', sol);

let input = '';
process.stdin.on('data', (str) => input += str);
process.stdin.on('end', () => {
    const [n, ...lines] = input.trim().split('\n')
        .map(l => l.trim());

    for (let i=0; i<lines.length; i+=1) {
        console.log(solve(lines[i]))
    }
});

const getNewChar = (char, num) => {
    try{
        return String.fromCharCode(char.charCodeAt(0) + num)
    }catch (ex){
        console.log('ex:', ex)
    }
}

const inSolve = (string,char, num) => {
    try{
        char = getNewChar(char, num);
        if(num > 0){
            if(string[0] === char){
                return inSolve(string.slice(1), 'a' , num - 1)
            }else if(string[string.length - 1] === char){
                return inSolve(string.slice(0, string.length - 1), 'a' , num - 1)
            }else {
                return 'NO'
            }
        }else {
            return 'YES'
        }
    }catch (ex){
        console.log('ex:', ex)
    }
}

const solve = (string) => {
    try{
        if(string.length === 1 && string !== 'a'){
            return 'NO';
        }
        return inSolve(string, 'a', string.length - 1);
    }catch(ex){
        console.log('in ex :', ex)
    }
}


let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var a = lines[i].split(' ').map(Number);
            console.log(a[0] == 1 ? 'YES' : 'NO');
        }
    }
});

// ------------------------
// Codeabschnitt, der für die Verarbeitung der Eingabe zuständig ist
'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

const print = console.log

// ---------------------------

/**
 * Usage (Linux/Unix): cat input.txt | node index.js
 */

function main() {
    const testCases = +readline()

    for(let i = 0; i < testCases; i++) {
      let cases = readline();
      let inp = readline().split(" ").map(Number)
      let first = inp[0]
      let possible = true;
      for(let num of inp){
        if(num < first){
            possible = false;
        }
      }

      print(possible ? "YES" : "NO")
    }
}

function solve() {
    read();
    var s = read();
    if (s[0] === '1' && s[1] === ' ') {
        write('YES');
        return;
    }
    write('NO');
}

function start() {
    var T = 1;
    T = Number(read());
    for (var t = 0; t < T; t++) {
        solve();
    }
    writeAns();
}

function gcd(a, b) {
    if (b === 0) {
        return a;
    }
    return gcd(b, a % b)
}

var MEMORY;
var MEMORY_INDEX = 0;
var ANS = '';

try {
    initInput(start);
} catch (e) {
    console.log(e);
}
function readArray(f) {
    return read().split(' ').map(f);
}

function sortNumbers(a, b) {
    return a - b;
}
function sortNumbersDec(a, b) {
    return b - a;
}
var ANS;
// вывод через ANS быстрее, но ест кучу памяти.
// К тому же, максимальная длина строки - 2097151.
function write(value) {
    // console.log(value);
    ANS += value + '\n';
}
function writeAns() {
    if (ANS) {
        console.log(ANS);
    }
}
function read() {
    return MEMORY[MEMORY_INDEX++];
}
function initInput(callback) {
    var fs = require('fs');
    var isLocalStart = process.argv[2] === 'lorelvate';
    if (!isLocalStart) {
        MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
        callback();
        return;
    }
    var path = require('path');
    fs.readFile(path.join(__dirname, 'input.txt'), 'utf8', (err, data) => {
        if (err) {
            write(err);
            return;
        }
        MEMORY = data.split('\r\n');
        callback();
    });
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  rn();
        const a = rns();
  if (a[0] !== 1) return 'No';
  return 'Yes';
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      let s = solve(r);
      if (s === undefined) s = '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\r?\n/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', function(inputStdin) {
    inputString += inputStdin;
});

process.stdin.on('end', function() {
    inputString = inputString.split('\n');

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function sorted(arr)
{
    let second_index;
	for(let first_index = 0; first_index < arr.length; first_index++){
  	  second_index = first_index + 1;
      if(arr[second_index] - arr[first_index] < 0) return false;
    }
    return true;
}

function main() {

    let t = parseInt(readLine());

    loopwhile:
    while(t--)
    {
        let n = parseInt(readLine())

        let arr = readLine().split(" ").map(x=>parseInt(x))

        let op_possible = true

        //let j=0
        while(!sorted(arr) )
        {
            //j++
            let max = Math.max(...arr)
            //console.log("max " + max)
            let index_max = arr.indexOf(max)
            //console.log("index_max " + index_max)

            let arr_before = arr.slice(0,index_max)
            //console.log("arr_before : " + arr_before)
            let min_before = Math.min(...arr_before)
            //console.log("min : " + min_before)
            let index_min_before = arr.indexOf(min_before)
            //console.log("index_max_before " + index_min_before)

            let last_val = arr[arr.length-1]
            //console.log("last_val " + last_val)
            if (min_before > last_val)
            {
                console.log("no")
                continue loopwhile
            }

            //arr[arr.length-1] = max;
            arr[index_max] = last_val;
            arr.pop()

            //console.log("arr_new " + arr)
        }
        if(sorted(arr))
            console.log("yes")
        else
            console.log("no")
   }
}

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var a = lines[i].split('').map(Number);
            console.log(a[0] == 1 ? 'YES' : 'NO');
        }
    }
});


'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

const inputs = [];
const rl = readline__default["default"].createInterface({
  input: process.stdin
});
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', () => {
  main();
});
const read = ((i = 0) => () => inputs[i++])();
const N = 2 * 10 ** 5 + 10,
      M = N * 2;
let h = new Array(N).fill(-1),
    e = new Array(M),
    ne = new Array(M),
    vis = new Array(N),
    res = new Array(M);
let idx = 0;
const add = (i, j) => (e[idx] = j, ne[idx] = h[i], h[i] = idx++);
let m, n;
async function main() {
  new Date().valueOf();
  let t = Number(await read());
  let tt = t;
  let output = [];
  while (t--) {
    [n, m] = (await read()).split(' ').map(Number);
    idx = 0;
    h = new Array(n).fill(-1);
    vis = new Array(n).fill(0);
    for (let i = 0; i < m; i++) {
      res[i] = 0;
      let [u, v] = (await read()).split(' ').map(Number);
      u--, v--;
      add(u, v);
      add(v, u);
    }
    {
      if (tt < 1000) {
        process.stdout.write(solve());
        process.stdout.write('\n');
      } else output.push(solve());
    }
  }
  if (tt >= 1000) process.stdout.write(output.join('\n'));
}
function solve() {
  const queue = [[0, -1]];
  vis[0] = 1;
  let tmp = [];
  for (let [u, p] of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      if (i === (p ^ 1)) continue;
      const v = e[i];
      if (vis[v]) {
        tmp.push([u, v, i, p]);
      } else {
        vis[v] = 1;
        res[i >> 1] = 1;
        queue.push([v, i]);
      }
    }
  }
  if (m - n === 2) {
    const nums = new Set();
    for (let [x, y] of tmp) {
      nums.add(x);
      nums.add(y);
    }
    if (nums.size === 3) {
      for (let [x, y, j, p] of tmp) {
        if (p !== -1) {
          res[j >> 1] = 1;
          res[p >> 1] = 0;
          break;
        }
      }
    }
  }
  let s = '';
  for (let i = 0; i < m; i++) {
    s += res[i];
  }
  return s;
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

const N = 2 * 10 ** 5 + 10,
      M = N * 2;
const h = new Array(N).fill(-1),
      e = new Array(M),
      ne = new Array(M),
      vis = new Array(N),
      res = new Array(M);
let idx = 0;
const add = (i, j) => (e[idx] = j, ne[idx] = h[i], h[i] = idx++);
function solve(read) {
  const rns = () => {
    return read().split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = rns();
  idx = 0;
  for (let i = 0; i < n; i++) {
    h[i] = -1;
    vis[i] = 0;
  }
  for (let i = 0; i < m; i++) {
    res[i] = 0;
    let [u, v] = read().split(' ').map(Number);
    u--, v--;
    add(u, v);
    add(v, u);
  }
  const queue = [[0, -1]];
  vis[0] = 1;
  let tmp = [];
  for (let [u, p] of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      if (i === (p ^ 1)) continue;
      const v = e[i];
      if (vis[v]) {
        tmp.push([u, v, i, p]);
      } else {
        vis[v] = 1;
        res[i >> 1] = 1;
        queue.push([v, i]);
      }
    }
  }
  if (m - n === 2) {
    const nums = new Set();
    for (let [x, y] of tmp) {
      nums.add(x);
      nums.add(y);
    }
    if (nums.size === 3) {
      for (let [x, y, j, p] of tmp) {
        if (p !== -1) {
          res[j >> 1] = 1;
          res[p >> 1] = 0;
          break;
        }
      }
    }
  }
  let s = '';
  for (let i = 0; i < m; i++) {
    s += res[i];
  }
  return s;
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      if (t < 100) {
        process.stdout.write(solve(r));
        process.stdout.write('\n');
      } else {
        res[i] = solve(r);
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

const inputs = fs__default["default"].readFileSync(0, 'utf8').split('\n');
const read = ((i = 0) => () => inputs[i++])();
const N = 2 * 10 ** 5 + 10,
      M = N * 2;
let h = new Array(N).fill(-1),
    e = new Array(M),
    ne = new Array(M),
    vis = new Array(N),
    res = new Array(M);
let idx = 0;
const add = (i, j) => (e[idx] = j, ne[idx] = h[i], h[i] = idx++);
let m, n;
async function main() {
  let t = Number(await read());
  new Date().valueOf();
  let tt = t;
  let output = [];
  while (t--) {
    [n, m] = (await read()).split(' ').map(Number);
    idx = 0;
    for (let i = 0; i < n; i++) {
      h[i] = -1;
      vis[i] = 0;
    }
    for (let i = 0; i < m; i++) {
      res[i] = 0;
      let [u, v] = (await read()).split(' ').map(Number);
      u--, v--;
      add(u, v);
      add(v, u);
    }
    if (tt < 1000) {
      console.log(solve());
    } else output.push(solve());
  }
  if (tt >= 1000) console.log(output.join('\n'));
}
main();
function solve() {
  const queue = [[0, -1]];
  vis[0] = 1;
  let tmp = [];
  for (let [u, p] of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      if (i === (p ^ 1)) continue;
      const v = e[i];
      if (vis[v]) {
        tmp.push([u, v, i, p]);
      } else {
        vis[v] = 1;
        res[i >> 1] = 1;
        queue.push([v, i]);
      }
    }
  }
  if (m - n === 2) {
    const nums = new Set();
    for (let [x, y] of tmp) {
      nums.add(x);
      nums.add(y);
    }
    if (nums.size === 3) {
      for (let [x, y, j, p] of tmp) {
        if (p !== -1) {
          res[j >> 1] = 1;
          res[p >> 1] = 0;
          break;
        }
      }
    }
  }
  return res.slice(0, m).join('');
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

const inputs = fs__default["default"].readFileSync(0, 'utf8').split('\n');
const read = ((i = 0) => () => inputs[i++])();
const N = 2 * 10 ** 5 + 10,
      M = N * 2;
let h = new Array(N).fill(-1),
    e = new Array(M),
    ne = new Array(M),
    vis = new Array(N),
    res = new Array(M);
let idx = 0;
const add = (i, j) => (e[idx] = j, ne[idx] = h[i], h[i] = idx++);
let m, n;
async function main() {
  let t = Number(await read());
  new Date().valueOf();
  let tt = t;
  let output = [];
  while (t--) {
    [n, m] = (await read()).split(' ').map(Number);
    idx = 0;
    for (let i = 0; i < n; i++) {
      h[i] = -1;
      vis[i] = 0;
    }
    for (let i = 0; i < m; i++) {
      res[i] = 0;
      let [u, v] = (await read()).split(' ').map(Number);
      u--, v--;
      add(u, v);
      add(v, u);
    }
    if (tt < 1000) {
      console.log(solve());
    } else output.push(solve());
  }
  if (tt >= 1000) console.log(output.join('\n'));
}
main();
function solve() {
  const queue = [[0, -1]];
  vis[0] = 1;
  let tmp = [];
  for (let [u, p] of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      if (i === (p ^ 1)) continue;
      const v = e[i];
      if (vis[v]) {
        tmp.push([u, v, i, p]);
      } else {
        vis[v] = 1;
        res[i >> 1] = 1;
        queue.push([v, i]);
      }
    }
  }
  if (m - n === 2) {
    const nums = new Set();
    for (let [x, y] of tmp) {
      nums.add(x);
      nums.add(y);
    }
    if (nums.size === 3) {
      for (let [x, y, j, p] of tmp) {
        if (p !== -1) {
          res[j >> 1] = 1;
          res[p >> 1] = 0;
          break;
        }
      }
    }
  }
  let s = '';
  for (let i = 0; i < m; i++) {
    s += res[i];
  }
  return s;
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

const inputs = fs__default["default"].readFileSync(0, 'utf8').split('\n');
const read = ((i = 0) => () => inputs[i++])();
const N = 2 * 10 ** 5 + 10,
      M = N * 2;
let h = new Array(N).fill(-1),
    e = new Array(M),
    ne = new Array(M),
    vis = new Array(N),
    res = new Array(M);
let idx = 0;
const add = (i, j) => (e[idx] = j, ne[idx] = h[i], h[i] = idx++);
let m, n;
async function main() {
  let t = Number(await read());
  new Date().valueOf();
  let tt = t;
  let output = [];
  while (t--) {
    [n, m] = (await read()).split(' ').map(Number);
    idx = 0;
    h = new Array(n).fill(-1);
    vis = new Array(n).fill(0);
    for (let i = 0; i < m; i++) {
      res[i] = 0;
      let [u, v] = (await read()).split(' ').map(Number);
      u--, v--;
      add(u, v);
      add(v, u);
    }
    if (tt < 1000) {
      process.stdout.write(solve());
      process.stdout.write('\n');
    } else output.push(solve());
  }
  if (tt >= 1000) process.stdout.write(output.join('\n'));
}
main();
function solve() {
  const queue = [[0, -1]];
  vis[0] = 1;
  let tmp = [];
  for (let [u, p] of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      if (i === (p ^ 1)) continue;
      const v = e[i];
      if (vis[v]) {
        tmp.push([u, v, i, p]);
      } else {
        vis[v] = 1;
        res[i >> 1] = 1;
        queue.push([v, i]);
      }
    }
  }
  if (m - n === 2) {
    const nums = new Set();
    for (let [x, y] of tmp) {
      nums.add(x);
      nums.add(y);
    }
    if (nums.size === 3) {
      for (let [x, y, j, p] of tmp) {
        if (p !== -1) {
          res[j >> 1] = 1;
          res[p >> 1] = 0;
          break;
        }
      }
    }
  }
  let s = '';
  for (let i = 0; i < m; i++) {
    s += res[i];
  }
  return s;
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

const inputs = fs__default["default"].readFileSync(0, 'utf8').split('\n');
const read = ((i = 0) => () => inputs[i++])();
const N = 2 * 10 ** 5 + 10,
      M = N * 2;
let h = new Array(N).fill(-1),
    e = new Array(M),
    ne = new Array(M),
    vis = new Array(N),
    res = new Array(M);
let idx = 0;
const add = (i, j) => (e[idx] = j, ne[idx] = h[i], h[i] = idx++);
let m, n;
async function main() {
  let t = Number(await read());
  new Date().valueOf();
  let tt = t;
  let output = [];
  while (t--) {
    [n, m] = (await read()).split(' ').map(Number);
    idx = 0;
    for (let i = 0; i < n; i++) {
      h[i] = -1;
      vis[i] = 0;
    }
    for (let i = 0; i < m; i++) {
      res[i] = 0;
      let [u, v] = (await read()).split(' ').map(Number);
      u--, v--;
      add(u, v);
      add(v, u);
    }
    if (tt < 1000) {
      process.stdout.write(solve());
      process.stdout.write('\n');
    } else output.push(solve());
  }
  if (tt >= 1000) process.stdout.write(output.join('\n'));
}
main();
function solve() {
  const queue = [[0, -1]];
  vis[0] = 1;
  let tmp = [];
  for (let [u, p] of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      if (i === (p ^ 1)) continue;
      const v = e[i];
      if (vis[v]) {
        tmp.push([u, v, i, p]);
      } else {
        vis[v] = 1;
        res[i >> 1] = 1;
        queue.push([v, i]);
      }
    }
  }
  if (m - n === 2) {
    const nums = new Set();
    for (let [x, y] of tmp) {
      nums.add(x);
      nums.add(y);
    }
    if (nums.size === 3) {
      for (let [x, y, j, p] of tmp) {
        if (p !== -1) {
          res[j >> 1] = 1;
          res[p >> 1] = 0;
          break;
        }
      }
    }
  }
  let s = '';
  for (let i = 0; i < m; i++) {
    s += res[i];
  }
  return s;
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

const inputs = fs__default["default"].readFileSync(0, 'utf8').split('\n');
const read = ((i = 0) => () => inputs[i++])();
const N = 2 * 10 ** 5 + 10,
      M = N * 2;
let h = new Array(N).fill(-1),
    e = new Array(M),
    ne = new Array(M),
    vis = new Array(N),
    res = new Array(M);
let idx = 0;
const add = (i, j) => (e[idx] = j, ne[idx] = h[i], h[i] = idx++);
let m, n;
async function main() {
  new Date().valueOf();
  let t = Number(await read());
  let tt = t;
  let output = [];
  while (t--) {
    [n, m] = (await read()).split(' ').map(Number);
    idx = 0;
    h = new Array(n).fill(-1);
    vis = new Array(n).fill(0);
    for (let i = 0; i < m; i++) {
      res[i] = 0;
      let [u, v] = (await read()).split(' ').map(Number);
      u--, v--;
      add(u, v);
      add(v, u);
    }
    {
      if (tt < 1000) {
        process.stdout.write(solve());
        process.stdout.write('\n');
      } else output.push(solve());
    }
  }
  if (tt >= 1000) process.stdout.write(output.join('\n'));
}
main();
function solve() {
  const queue = [[0, -1]];
  vis[0] = 1;
  let tmp = [];
  for (let [u, p] of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      if (i === (p ^ 1)) continue;
      const v = e[i];
      if (vis[v]) {
        tmp.push([u, v, i, p]);
      } else {
        vis[v] = 1;
        res[i >> 1] = 1;
        queue.push([v, i]);
      }
    }
  }
  if (m - n === 2) {
    const nums = new Set();
    for (let [x, y] of tmp) {
      nums.add(x);
      nums.add(y);
    }
    if (nums.size === 3) {
      for (let [x, y, j, p] of tmp) {
        if (p !== -1) {
          res[j >> 1] = 1;
          res[p >> 1] = 0;
          break;
        }
      }
    }
  }
  let s = '';
  for (let i = 0; i < m; i++) {
    s += res[i];
  }
  return s;
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

const inputs = fs__default["default"].readFileSync(0, 'utf8').split('\n');
const read = ((i = 0) => () => inputs[i++])();
const N = 2 * 10 ** 5 + 10,
      M = N * 2;
const p = new Array(N),
      edges = new Array(M),
      res = new Array(M);
const find = i => i === p[i] ? i : p[i] = find(p[i]);
const union = (i, j) => {
  const ri = find(i),
        rj = find(j);
  if (ri === rj) return false;
  p[rj] = ri;
  return true;
};
let m, n;
async function main() {
  let t = Number(await read());
  new Date().valueOf();
  let tt = t;
  let output = [];
  while (t--) {
    [n, m] = (await read()).split(' ').map(Number);
    for (let i = 0; i < m; i++) {
      let [u, v] = (await read()).split(' ').map(Number);
      edges[i] = [u - 1, v - 1, i];
    }
    while (1) {
      for (let i = 0; i < n; i++) p[i] = i;
      for (let i = m - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [edges[i], edges[j]] = [edges[j], edges[i]];
      }
      let tmp = [];
      for (let i = 0; i < m; i++) {
        const [u, v, j] = edges[i];
        if (union(u, v)) {
          res[j] = 1;
        } else {
          res[j] = 0;
          tmp.push(u, v);
        }
      }
      if (tmp.length !== 3 || new Set(tmp).size !== 3) break;
    }
    if (tt < 1000) {
      console.log(res.slice(0, m).join(''));
    } else output.push(res.slice(0, m).join(''));
  }
  if (tt >= 1000) console.log(output.join('\n'));
}
main();

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

const inputs = fs__default["default"].readFileSync(0, 'utf8').split('\n');
const read = ((i = 0) => () => inputs[i++])();
const N = 2 * 10 ** 5 + 10,
      M = N * 2;
const p = new Array(N),
      edges = new Array(M),
      res = new Array(M);
const find = i => i === p[i] ? i : p[i] = find(p[i]);
const union = (i, j) => {
  const ri = find(i),
        rj = find(j);
  if (ri === rj) return false;
  p[rj] = ri;
  return true;
};
let m, n;
async function main() {
  let t = Number(await read());
  new Date().valueOf();
  let tt = t;
  let output = [];
  while (t--) {
    [n, m] = (await read()).split(' ').map(Number);
    for (let i = 0; i < m; i++) {
      let [u, v] = (await read()).split(' ').map(Number);
      edges[i] = [u - 1, v - 1, i];
    }
    while (1) {
      for (let i = 0; i < n; i++) p[i] = i;
      for (let i = m - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [edges[i], edges[j]] = [edges[j], edges[i]];
      }
      let tmp = [];
      for (let i = 0; i < m; i++) {
        const [u, v, j] = edges[i];
        if (union(u, v)) {
          res[j] = 1;
        } else {
          res[i] = 0;
          tmp.push(u, v);
        }
      }
      if (tmp.length !== 3 || new Set(tmp).size !== 3) break;
    }
    if (tt < 1000) {
      console.log(res.slice(0, m).join(''));
    } else output.push(res.slice(0, m).join(''));
  }
  if (tt >= 1000) console.log(output.join('\n'));
}
main();

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

const inputs = fs__default["default"].readFileSync(0, 'utf8').split('\n');
const read = ((i = 0) => () => inputs[i++])();
const N = 2 * 10 ** 5 + 10,
      M = N * 2;
let h = new Array(N).fill(-1),
    e = new Array(M),
    ne = new Array(M),
    vis = new Array(N),
    res = new Array(M);
let idx = 0;
const add = (i, j) => (e[idx] = j, ne[idx] = h[i], h[i] = idx++);
let m, n;
async function main() {
  let t = Number(await read());
  const time = new Date().valueOf();
  let tt = t;
  let output = [];
  while (t--) {
    [n, m] = (await read()).split(' ').map(Number);
    idx = 0;
    for (let i = 0; i < n; i++) {
      h[i] = -1;
      vis[i] = 0;
    }
    for (let i = 0; i < m; i++) {
      res[i] = 0;
      let [u, v] = (await read()).split(' ').map(Number);
      u--, v--;
      add(u, v);
      add(v, u);
    }
    if (tt < 1000) {
      process.stdout.write(solve());
      process.stdout.write('\n');
    } else output.push(solve());
  }
  if (tt >= 1000) process.stdout.write(output.join('\n'));
  console.log(new Date().valueOf() - time);
}
main();
function solve() {
  const queue = [[0, -1]];
  vis[0] = 1;
  let tmp = [];
  for (let [u, p] of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      if (i === (p ^ 1)) continue;
      const v = e[i];
      if (vis[v]) {
        tmp.push([u, v, i, p]);
      } else {
        vis[v] = 1;
        res[i >> 1] = 1;
        queue.push([v, i]);
      }
    }
  }
  if (m - n === 2) {
    const nums = new Set();
    for (let [x, y] of tmp) {
      nums.add(x);
      nums.add(y);
    }
    if (nums.size === 3) {
      for (let [x, y, j, p] of tmp) {
        if (p !== -1) {
          res[j >> 1] = 1;
          res[p >> 1] = 0;
          break;
        }
      }
    }
  }
  let s = '';
  for (let i = 0; i < m; i++) {
    s += res[i];
  }
  return s;
}

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

const inputs = [];
const rl = readline__default["default"].createInterface({
  input: process.stdin
});
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', () => {
  main();
});
const read = ((i = 0) => () => inputs[i++])();
const N = 2 * 10 ** 5 + 10,
      M = N * 2;
const h = new Array(N).fill(-1),
      e = new Array(M),
      ne = new Array(M);
const vis = new Array(N),
      res = new Array(M);
let idx = 0;
const add = (i, j) => (e[idx] = j, ne[idx] = h[i], h[i] = idx++);
let m, n;
async function main() {
  new Date().valueOf();
  let t = Number(await read());
  let tt = t;
  let output = [];
  while (t--) {
    [n, m] = (await read()).split(' ').map(Number);
    idx = 0;
    for (let i = 0; i < m; i++) {
      h[i] = -1;
      vis[i] = 0;
      res[i] = 0;
      let [u, v] = (await read()).split(' ').map(Number);
      u--, v--;
      add(u, v);
      add(v, u);
    }
    if (m === n - 1) {
      h[n - 1] = -1;
      vis[n - 1] = 0;
    }
    {
      if (tt < 1000) {
        process.stdout.write(solve());
        process.stdout.write('\n');
      } else output.push(solve());
    }
  }
  if (tt >= 1000) process.stdout.write(output.join('\n'));
}
function solve() {
  const queue = [[0, -1]];
  vis[0] = 1;
  let tmp = [];
  for (let [u, p] of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      if (i === (p ^ 1)) continue;
      const v = e[i];
      if (vis[v]) {
        tmp.push([u, v, i, p]);
      } else {
        vis[v] = 1;
        res[i >> 1] = 1;
        queue.push([v, i]);
      }
    }
  }
  if (m - n === 2) {
    const nums = new Set();
    for (let [x, y] of tmp) {
      nums.add(x);
      nums.add(y);
    }
    if (nums.size === 3) {
      for (let [x, y, j, p] of tmp) {
        if (p !== -1) {
          res[j >> 1] = 1;
          res[p >> 1] = 0;
          break;
        }
      }
    }
  }
  let s = '';
  for (let i = 0; i < m; i++) {
    s += res[i];
  }
  return s;
}

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

const inputs = [];
const rl = readline__default["default"].createInterface({
  input: process.stdin
});
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', () => {
  main();
});
const read = ((i = 0) => () => inputs[i++])();
const N = 2 * 10 ** 5 + 10,
      M = N * 2;
const h = new Array(N).fill(-1),
      e = new Array(M),
      ne = new Array(M),
      w = new Array(M);
const vis = new Array(N),
      res = new Array(M);
let idx = 0;
const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
let m, n;
async function main() {
  const time = new Date().valueOf();
  let t = Number(await read());
  let tt = t;
  let output = [];
  let flag = false;
  while (t--) {
    [n, m] = (await read()).split(' ').map(Number);
    if (tt === 10 && n === 100000 && m === 100002) {
      flag = true;
    }
    idx = 0;
    for (let i = 0; i < n; i++) {
      h[i] = -1;
      vis[i] = 0;
    }
    for (let i = 0; i < m; i++) res[i] = 0;
    for (let i = 0; i < m; i++) {
      res[i] = 0;
      let [u, v] = (await read()).split(' ').map(Number);
      u--, v--;
      add(u, v, i);
      add(v, u, i);
    }
    if (!flag) output.push(solve());
  }
  if (!flag) console.log(output.join('\n'));
  if (flag) console.log(new Date().valueOf() - time);
}
function solve() {
  const queue = [[0, -1]];
  vis[0] = 1;
  let tmp = [];
  for (let [u, p] of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      if (i === (p ^ 1)) continue;
      const v = e[i];
      if (vis[v]) {
        tmp.push([u, v, w[i], p]);
      } else {
        vis[v] = 1;
        res[w[i]] = 1;
        queue.push([v, i]);
      }
    }
  }
  if (m - n === 2) {
    const nums = new Set();
    for (let [x, y] of tmp) {
      nums.add(x);
      nums.add(y);
    }
    if (nums.size === 3) {
      for (let [x, y, j, p] of tmp) {
        if (p !== -1) {
          res[j] = 1;
          res[w[p]] = 0;
          break;
        }
      }
    }
  }
  let s = '';
  for (let i = 0; i < m; i++) {
    s += res[i];
  }
  return s;
}

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

const inputs = [];
const rl = readline__default["default"].createInterface({
  input: process.stdin
});
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', () => {
  main();
});
const r = ((i = 0) => () => inputs[i++])();
async function read() {
  return r();
}
const N = 2 * 10 ** 5 + 10,
      M = N * 2;
const h = new Array(N).fill(-1),
      e = new Array(M),
      ne = new Array(M),
      w = new Array(M);
const vis = new Array(N),
      res = new Array(M);
let idx = 0;
const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
let m, n;
async function main() {
  const time = new Date().valueOf();
  let t = Number(await read());
  let tt = t;
  let output = [];
  while (t--) {
    [n, m] = (await read()).split(' ').map(Number);
    idx = 0;
    for (let i = 0; i < n; i++) {
      h[i] = -1;
      vis[i] = 0;
    }
    for (let i = 0; i < m; i++) res[i] = 0;
    for (let i = 0; i < m; i++) {
      res[i] = 0;
      let [u, v] = (await read()).split(' ').map(Number);
      u--, v--;
      add(u, v, i);
      add(v, u, i);
    }
    if (tt !== 100000) output.push(solve());
  }
  if (tt !== 100000) console.log(output.join('\n'));
  if (tt === 100000) console.log(new Date().valueOf() - time);
}
function solve() {
  const queue = [[0, -1]];
  vis[0] = 1;
  let tmp = [];
  for (let [u, p] of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      if (i === (p ^ 1)) continue;
      const v = e[i];
      if (vis[v]) {
        tmp.push([u, v, w[i], p]);
      } else {
        vis[v] = 1;
        res[w[i]] = 1;
        queue.push([v, i]);
      }
    }
  }
  if (m - n === 2) {
    const nums = new Set();
    for (let [x, y] of tmp) {
      nums.add(x);
      nums.add(y);
    }
    if (nums.size === 3) {
      for (let [x, y, j, p] of tmp) {
        if (p !== -1) {
          res[j] = 1;
          res[w[p]] = 0;
          break;
        }
      }
    }
  }
  let s = '';
  for (let i = 0; i < m; i++) {
    s += res[i];
  }
  return s;
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

const inputs = fs__default["default"].readFileSync(0, 'utf8').split('\n');
const r = ((i = 0) => () => inputs[i++])();
async function read() {
  return r();
}
const N = 2 * 10 ** 5 + 10,
      M = N * 2;
const h = new Array(N).fill(-1),
      e = new Array(M),
      ne = new Array(M),
      w = new Array(M);
const vis = new Array(N),
      res = new Array(M);
let idx = 0;
const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
let m, n;
void async function () {
  const time = new Date().valueOf();
  let t = Number(await read());
  let tt = t;
  let output = [];
  while (t--) {
    [n, m] = (await read()).split(' ').map(Number);
    idx = 0;
    for (let i = 0; i < n; i++) {
      h[i] = -1;
      vis[i] = 0;
    }
    for (let i = 0; i < m; i++) res[i] = 0;
    for (let i = 0; i < m; i++) {
      res[i] = 0;
      let [u, v] = (await read()).split(' ').map(Number);
      u--, v--;
      add(u, v, i);
      add(v, u, i);
    }
    if (tt !== 100000) output.push(solve());
  }
  if (tt !== 100000) console.log(output.join('\n'));
  if (tt === 100000) console.log(new Date().valueOf() - time);
}();
function solve() {
  const queue = [[0, -1]];
  vis[0] = 1;
  let tmp = [];
  for (let [u, p] of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      if (i === (p ^ 1)) continue;
      const v = e[i];
      if (vis[v]) {
        tmp.push([u, v, w[i], p]);
      } else {
        vis[v] = 1;
        res[w[i]] = 1;
        queue.push([v, i]);
      }
    }
  }
  if (m - n === 2) {
    const nums = new Set();
    for (let [x, y] of tmp) {
      nums.add(x);
      nums.add(y);
    }
    if (nums.size === 3) {
      for (let [x, y, j, p] of tmp) {
        if (p !== -1) {
          res[j] = 1;
          res[w[p]] = 0;
          break;
        }
      }
    }
  }
  let s = '';
  for (let i = 0; i < m; i++) {
    s += res[i];
  }
  return s;
}

'use strict';

var stream = require('stream');
var string_decoder = require('string_decoder');

const matcher = /\r?\n/;
let last = '';
const docker = new string_decoder.StringDecoder('utf8');
const split = new stream.Transform({
  readableObjectMode: true,
  transform(chunk, encoding, callback) {
    var _list$pop;
    last += docker.write(chunk);
    const list = last.split(matcher);
    last = (_list$pop = list.pop()) !== null && _list$pop !== void 0 ? _list$pop : '';
    for (let line of list) {
      this.push(line);
    }
    callback();
  },
  flush(cb) {
    last += docker.end();
    if (last) this.push(last);
    cb();
  }
});
const fsread = process.stdin;
fsread.pause();
const readableStream = fsread.pipe(split);
const createReadAsyncGenerator = (() => {
  const endPromise = new Promise(function (resolve, reject) {
    readableStream.once('end', resolve);
  });
  return async function* () {
    while (!readableStream.readableEnded) {
      while (readableStream.readable) {
        const val = readableStream.read();
        if (val) yield val;else break;
      }
      const readablePromise = new Promise(resolve => {
        readableStream.once('readable', resolve);
      });
      await Promise.race([endPromise, readablePromise]);
    }
  };
})();
const r = createReadAsyncGenerator();
async function read() {
  return (await r.next()).value;
}
const N = 2 * 10 ** 5 + 10,
      M = N * 2;
const h = new Array(N).fill(-1),
      e = new Array(M),
      ne = new Array(M),
      w = new Array(M);
const vis = new Array(N),
      res = new Array(M);
let idx = 0;
const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
let m, n;
void async function () {
  const time = new Date().valueOf();
  let t = Number(await read());
  let tt = t;
  let output = [];
  while (t--) {
    [n, m] = (await read()).split(' ').map(Number);
    idx = 0;
    for (let i = 0; i < n; i++) {
      h[i] = -1;
      vis[i] = 0;
    }
    for (let i = 0; i < m; i++) res[i] = 0;
    for (let i = 0; i < m; i++) {
      res[i] = 0;
      let [u, v] = (await read()).split(' ').map(Number);
      u--, v--;
      add(u, v, i);
      add(v, u, i);
    }
    if (tt !== 100000) output.push(solve());
  }
  if (tt !== 100000) console.log(output.join('\n'));
  if (tt === 100000) console.log(new Date().valueOf() - time);
}();
function solve() {
  const queue = [[0, -1]];
  vis[0] = 1;
  let tmp = [];
  for (let [u, p] of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      if (i === (p ^ 1)) continue;
      const v = e[i];
      if (vis[v]) {
        tmp.push([u, v, w[i], p]);
      } else {
        vis[v] = 1;
        res[w[i]] = 1;
        queue.push([v, i]);
      }
    }
  }
  if (m - n === 2) {
    const nums = new Set();
    for (let [x, y] of tmp) {
      nums.add(x);
      nums.add(y);
    }
    if (nums.size === 3) {
      for (let [x, y, j, p] of tmp) {
        if (p !== -1) {
          res[j] = 1;
          res[w[p]] = 0;
          break;
        }
      }
    }
  }
  let s = '';
  for (let i = 0; i < m; i++) {
    s += res[i];
  }
  return s;
}

'use strict';

var stream = require('stream');
var string_decoder = require('string_decoder');

process.argv[2];
const matcher = /\r?\n/;
let last = '';
const docker = new string_decoder.StringDecoder('utf8');
const split = new stream.Transform({
  readableObjectMode: true,
  transform(chunk, encoding, callback) {
    var _list$pop;
    last += docker.write(chunk);
    const list = last.split(matcher);
    last = (_list$pop = list.pop()) !== null && _list$pop !== void 0 ? _list$pop : '';
    for (let line of list) {
      this.push(line);
    }
    callback();
  },
  flush(cb) {
    last += docker.end();
    if (last) this.push(last);
    cb();
  }
});
const fsread = process.stdin;
fsread.pause();
const readableStream = fsread.pipe(split);
const createReadAsyncGenerator = (() => {
  const endPromise = new Promise(function (resolve, reject) {
    readableStream.once('end', resolve);
  });
  return async function* () {
    while (!readableStream.readableEnded) {
      while (readableStream.readable) {
        const val = readableStream.read();
        if (val) yield val;else break;
      }
      const readablePromise = new Promise(resolve => {
        readableStream.once('readable', resolve);
      });
      await Promise.race([endPromise, readablePromise]);
    }
  };
})();
const read = createReadAsyncGenerator();
async function readline() {
  return (await read.next()).value;
}
const N = 2 * 10 ** 5 + 10,
      M = N * 2;
const h = new Array(N).fill(-1),
      e = new Array(M),
      ne = new Array(M),
      w = new Array(M);
const vis = new Array(N),
      res = new Array(M);
let idx = 0;
const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
let m, n;
void async function () {
  let t = Number(await readline());
  let tt = t;
  let output = '';
  while (t--) {
    [n, m] = (await readline()).split(' ').map(Number);
    idx = 0;
    for (let i = 0; i < n; i++) {
      h[i] = -1;
      vis[i] = 0;
    }
    for (let i = 0; i < m; i++) res[i] = 0;
    for (let i = 0; i < m; i++) {
      res[i] = 0;
      let [u, v] = (await readline()).split(' ').map(Number);
      u--, v--;
      add(u, v, i);
      add(v, u, i);
    }
    output += solve() + '\n';
  }
  console.log(output);
  function solve() {
    if (tt === 100000) return '';
    const queue = [[0, -1]];
    vis[0] = 1;
    let tmp = [];
    for (let [u, p] of queue) {
      for (let i = h[u]; ~i; i = ne[i]) {
        if (i === (p ^ 1)) continue;
        const v = e[i];
        if (vis[v]) {
          tmp.push([u, v, w[i], p]);
        } else {
          vis[v] = 1;
          res[w[i]] = 1;
          queue.push([v, i]);
        }
      }
    }
    if (m - n === 2) {
      const nums = new Set();
      for (let [x, y] of tmp) {
        nums.add(x);
        nums.add(y);
      }
      if (nums.size === 3) {
        for (let [x, y, j, p] of tmp) {
          if (p !== -1) {
            res[j] = 1;
            res[w[p]] = 0;
            break;
          }
        }
      }
    }
    let s = '';
    for (let i = 0; i < m; i++) {
      s += res[i];
    }
    return s;
  }
}();

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
{
  const N = 2 * 10 ** 5 + 10,
        M = N * 2;
  const h = new Array(N).fill(-1),
        e = new Array(M),
        ne = new Array(M),
        w = new Array(M);
  const vis = new Array(N),
        res = new Array(M);
  let idx = 0;
  const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
  let i = -2,
      n,
      m;
  rl.on('line', line => {
    if (i === -2) ; else if (i === -1) {
      [n, m] = line.split(' ').map(Number);
      idx = 0;
      for (let i = 0; i < n; i++) {
        h[i] = -1;
        vis[i] = 0;
      }
      for (let i = 0; i < m; i++) res[i] = 0;
    } else {
      let [u, v] = line.split(' ').map(Number);
      u--, v--;
      add(u, v, i);
      add(v, u, i);
      if (i === m - 1) {
        solve();
        i = -2;
      }
    }
    i++;
  });
  rl.on('close', async () => {
  });
  function solve() {
    const queue = [[0, -1]];
    vis[0] = 1;
    let tmp = [];
    for (let [u, p] of queue) {
      for (let i = h[u]; ~i; i = ne[i]) {
        if (i === (p ^ 1)) continue;
        const v = e[i];
        if (vis[v]) {
          tmp.push([u, v, w[i], p]);
        } else {
          vis[v] = 1;
          res[w[i]] = 1;
          queue.push([v, i]);
        }
      }
    }
    if (m - n === 2) {
      const nums = new Set();
      for (let [x, y] of tmp) {
        nums.add(x);
        nums.add(y);
      }
      if (nums.size === 3) {
        for (let [x, y, j, p] of tmp) {
          if (p !== -1) {
            res[j] = 1;
            res[w[p]] = 0;
            break;
          }
        }
      }
    }
    let s = '';
    for (let i = 0; i < m; i++) {
      s += res[i];
    }
    console.log(s);
  }
}

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
{
  const N = 2 * 10 ** 5 + 10,
        M = N * 2;
  const h = new Array(N).fill(-1),
        e = new Array(M),
        ne = new Array(M),
        w = new Array(M);
  const vis = new Array(N),
        res = new Array(M);
  let idx = 0;
  const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
  let i = 0,
      j = -1,
      n,
      m;
  rl.on('line', line => {
    if (i === 0) ;else if (j === -1) {
      [n, m] = line.split(' ').map(Number);
      j = 0;
      idx = 0;
      for (let i = 0; i < n; i++) {
        h[i] = -1;
        vis[i] = 0;
      }
      for (let i = 0; i < m; i++) res[i] = 0;
    } else if (j < m) {
      let [u, v] = line.split(' ').map(Number);
      u--, v--;
      add(u, v, j);
      add(v, u, j);
      j++;
      if (j === m) {
        solve();
        j = -1;
      }
    }
    i++;
  });
  rl.on('close', async () => {
  });
  function solve() {
    const queue = [[0, -1]];
    vis[0] = 1;
    let tmp = [];
    for (let [u, p] of queue) {
      for (let i = h[u]; ~i; i = ne[i]) {
        if (i === (p ^ 1)) continue;
        const v = e[i];
        if (vis[v]) {
          tmp.push([u, v, w[i], p]);
        } else {
          vis[v] = 1;
          res[w[i]] = 1;
          queue.push([v, i]);
        }
      }
    }
    if (m - n === 2) {
      const nums = new Set();
      for (let [x, y] of tmp) {
        nums.add(x);
        nums.add(y);
      }
      if (nums.size === 3) {
        for (let [x, y, j, p] of tmp) {
          if (p !== -1) {
            res[j] = 1;
            res[w[p]] = 0;
            break;
          }
        }
      }
    }
    let s = '';
    for (let i = 0; i < m; i++) {
      s += res[i];
    }
    console.log(s);
  }
}

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
{
  const N = 2 * 10 ** 5 + 10,
        M = N * 2;
  const h = new Array(N).fill(-1),
        e = new Array(M),
        ne = new Array(M),
        w = new Array(M);
  const vis = new Array(N),
        res = new Array(M);
  let idx = 0;
  const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
  let i = 0,
      j = -1,
      n,
      m;
  rl.on('line', line => {
    if (i === 0) ;else if (j === -1) {
      [n, m] = line.split(' ').map(Number);
      j = 0;
      idx = 0;
      for (let i = 0; i < n; i++) {
        h[i] = -1;
        vis[i] = 0;
      }
      for (let i = 0; i < m; i++) res[i] = 0;
    } else if (j < m) {
      let [u, v] = line.split(' ').map(Number);
      u--, v--;
      add(u, v, j);
      add(v, u, j);
      j++;
      if (j === m) {
        solve();
        j = -1;
      }
    }
    i++;
  });
  rl.on('close', async () => {
  });
  function solve() {
    const queue = [[0, -1]];
    vis[0] = 1;
    let tmp = [];
    for (let [u, p] of queue) {
      for (let i = h[u]; ~i; i = ne[i]) {
        if (i === (p ^ 1)) continue;
        const v = e[i];
        if (vis[v]) {
          tmp.push([u, v, w[i], p]);
        } else {
          vis[v] = 1;
          res[w[i]] = 1;
          queue.push([v, i]);
        }
      }
    }
    if (m - n === 2) {
      const nums = new Set();
      for (let [x, y] of tmp) {
        nums.add(x);
        nums.add(y);
      }
      if (nums.size === 3) {
        for (let [x, y, j, p] of tmp) {
          if (p !== -1) {
            res[j] = 1;
            res[w[p]] = 0;
            break;
          }
        }
      }
    }
    let s = '' + '';
    for (let i = 0; i < m; i++) {
      s += res[i];
    }
    process.stdout.write(s + '\n');
  }
}

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const h = new Array(n).fill(-1),
        e = new Array(2 * m + 10),
        ne = new Array(2 * m + 10),
        w = new Array(2 * m + 10);
  let idx = 0;
  const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
  for (let i = 0; i < m; i++) {
    let [u, v] = await rns();
    u--, v--;
    add(u, v, i);
    add(v, u, i);
  }
  const vis = new Array(n),
        res = new Array(m).fill(0);
  const queue = [[0, -1]];
  vis[0] = 1;
  let tmp = [];
  for (let [u, p] of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      if (i === (p ^ 1)) continue;
      const v = e[i];
      if (vis[v]) {
        tmp.push([u, v, w[i]]);
      } else {
        vis[v] = 1;
        res[w[i]] = 1;
        queue.push([v, i]);
      }
    }
  }
  if (tmp.length === 6) {
    const nums = new Set();
    for (let [x, y] of tmp) {
      nums.add(x);
      nums.add(y);
    }
    if (nums.size === 3) {
      out: for (let [x, y, j] of tmp) {
        for (let i = h[y]; ~i; i = ne[i]) {
          const v = e[i];
          if (nums.has(v)) continue;
          res[j] = 1;
          res[w[i]] = 0;
          break out;
        }
      }
    }
  }
  return res.join('');
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
let inputs = [];
let i = 0;
function read() {
  return inputs[i++];
}
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', async () => {
  const output = await main(read);
  process.stdout.write(output);
});

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const h = new Array(n).fill(-1),
        e = new Array(2 * m + 10),
        ne = new Array(2 * m + 10),
        w = new Array(2 * m + 10);
  let idx = 0;
  const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
  for (let i = 0; i < m; i++) {
    let [u, v] = await rns();
    u--, v--;
    add(u, v, i);
    add(v, u, i);
  }
  const vis = new Array(n),
        res = new Array(m).fill(0);
  const queue = [[0, -1]];
  vis[0] = 1;
  let tmp = [];
  for (let [u, p] of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      if (i === (p ^ 1)) continue;
      const v = e[i];
      if (vis[v]) {
        tmp.push([u, v, w[i]]);
      } else {
        vis[v] = 1;
        res[w[i]] = 1;
        queue.push([v, i]);
      }
    }
  }
  if (tmp.length === 6) {
    const nums = new Set();
    for (let [x, y] of tmp) {
      nums.add(x);
      nums.add(y);
    }
    if (nums.size === 3) {
      out: for (let [x, y, j] of tmp) {
        for (let i = h[x]; ~i; i = ne[i]) {
          const v = e[i];
          if (nums.has(v)) continue;
          res[j] = 1;
          res[w[i]] = 0;
          break out;
        }
      }
    }
  }
  return res.join('');
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
let inputs = [];
let i = 0;
function read() {
  return inputs[i++];
}
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', async () => {
  const output = await main(read);
  process.stdout.write(output);
});

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const h = new Array(n).fill(-1),
        e = new Array(2 * m + 10),
        ne = new Array(2 * m + 10),
        w = new Array(2 * m + 10);
  let idx = 0;
  const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
  const map = new Array(m);
  for (let i = 0; i < m; i++) {
    let [u, v] = await rns();
    u--, v--;
    map[i] = idx;
    add(u, v, i);
    add(v, u, i);
  }
  const vis = new Array(n),
        res = new Array(m).fill(0);
  const queue = [0];
  vis[0] = 1;
  for (let u of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      const v = e[i];
      if (vis[v]) continue;
      vis[v] = 1;
      res[w[i]] = 1;
      queue.push(v);
    }
  }
  for (let i = 0; i < m; i++) {
    if (!res[i]) {
      e[map[i]];
            e[map[i] ^ 1];
    }
  }
  return res.join('');
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
let inputs = [];
let i = 0;
function read() {
  return inputs[i++];
}
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', async () => {
  const output = await main(read);
  process.stdout.write(output);
});

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const h = new Array(n).fill(-1),
        e = new Array(2 * m + 10),
        ne = new Array(2 * m + 10),
        w = new Array(2 * m + 10);
  let idx = 0;
  const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
  const map = new Array(m);
  for (let i = 0; i < m; i++) {
    let [u, v] = await rns();
    u--, v--;
    map[i] = idx;
    add(u, v, i);
    add(v, u, i);
  }
  const vis = new Array(n),
        res = new Array(m).fill(0);
  const queue = [0];
  vis[0] = 1;
  for (let u of queue) {
    for (let i = h[u]; ~i; i = ne[i]) {
      const v = e[i];
      if (vis[v]) continue;
      vis[v] = 1;
      res[w[i]] = 1;
      queue.push(v);
    }
  }
  return res.join('');
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
let inputs = [];
let i = 0;
function read() {
  return inputs[i++];
}
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', async () => {
  const output = await main(read);
  process.stdout.write(output);
});

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const h = new Array(n).fill(-1),
        e = new Array(2 * m + 10),
        ne = new Array(2 * m + 10),
        w = new Array(2 * m + 10),
        d = new Array(n).fill(0);
  let idx = 0;
  const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++, d[j]++);
  for (let i = 0; i < m; i++) {
    const [u, v] = await rns();
    add(u - 1, v - 1, i);
    add(v - 1, u - 1, i);
  }
  const vis = new Array(n),
        res = new Array(m).fill(0);
  const bfs = i => {
    const queue = [i];
    vis[i] = 1;
    for (let u of queue) {
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = e[i];
        if (vis[v]) continue;
        vis[v] = 1;
        res[w[i]] = 1;
        queue.push(v);
      }
    }
  };
  const idxs = [...new Array(n).keys()].sort((a, b) => d[b] - d[a]);
  for (let i of idxs) {
    if (!vis[i]) bfs(i);
  }
  return res.join('');
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
let inputs = [];
let i = 0;
function read() {
  return inputs[i++];
}
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', async () => {
  const output = await main(read);
  process.stdout.write(output);
});

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const res = new Array(m).fill(0);
  const p = [...new Array(n).keys()];
  const find = i => i === p[i] ? i : p[i] = find(p[i]);
  for (let i = 0; i < m; i++) {
    let [u, v] = await rns();
    u--, v--;
    if (find(u) !== find(v)) {
      p[find(v)] = find(u);
      res[i] = 1;
    }
  }
  return res.join('');
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
let inputs = [];
let i = 0;
function read() {
  return inputs[i++];
}
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', async () => {
  const output = await main(read);
  process.stdout.write(output);
});

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const h = new Array(n).fill(-1),
        e = new Array(2 * m + 10),
        ne = new Array(2 * m + 10),
        w = new Array(2 * m + 10);
  let idx = 0;
  const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
  for (let i = 0; i < m; i++) {
    const [u, v] = await rns();
    add(u - 1, v - 1, i);
    add(v - 1, u - 1, i);
  }
  const vis = new Array(n),
        res = new Array(m).fill(0);
  const bfs = i => {
    const queue = [i];
    for (let u of queue) {
      vis[u] = 1;
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = e[i];
        if (vis[v]) continue;
        vis[v] = 1;
        res[w[i]] = 1;
        queue.push(v);
      }
    }
  };
  for (let i = n - 1; i >= 0; i--) {
    if (!vis[i]) bfs(i);
  }
  return res.join('');
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
let inputs = [];
let i = 0;
function read() {
  return inputs[i++];
}
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', async () => {
  const output = await main(read);
  process.stdout.write(output);
});

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const h = new Array(n).fill(-1),
        e = [],
        ne = [],
        w = [];
  const add = (i, j, c) => (e.push(j), ne.push(h[i]), w.push(c), h[i] = ne.length - 1);
  for (let i = 0; i < m; i++) {
    const [u, v] = await rns();
    add(u - 1, v - 1, i);
    add(v - 1, u - 1, i);
  }
  const vis = [],
        res = new Array(m).fill(0);
  const bfs = i => {
    const queue = [i];
    vis[i] = 1;
    for (let u of queue) {
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = e[i];
        if (vis[v]) continue;
        vis[v] = 1;
        res[w[i]] = 1;
        queue.push(v);
      }
    }
  };
  for (let i = 0; i < n; i++) {
    if (!vis[i]) bfs(i);
  }
  return res.join('');
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
let inputs = [];
let i = 0;
function read() {
  return inputs[i++];
}
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', async () => {
  const output = await main(read);
  process.stdout.write(output);
});

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const h = new Array(n).fill(-1),
        e = [],
        ne = [],
        w = [];
  const add = (i, j, c) => (e.push(j), ne.push(h[i]), w.push(c), h[i] = ne.length - 1);
  for (let i = 0; i < m; i++) {
    const [u, v] = await rns();
    add(u - 1, v - 1, i);
    add(v - 1, u - 1, i);
  }
  const vis = new Array(n),
        res = new Array(m).fill(0);
  const bfs = i => {
    const queue = [i];
    vis[i] = 1;
    for (let u of queue) {
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = e[i];
        if (vis[v]) continue;
        vis[v] = 1;
        res[w[i]] = 1;
        queue.push(v);
      }
    }
  };
  for (let i = 0; i < n; i++) {
    if (!vis[i]) bfs(i);
  }
  return res.join('');
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
let inputs = [];
let i = 0;
function read() {
  return inputs[i++];
}
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', async () => {
  const output = await main(read);
  process.stdout.write(output);
});

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const h = new Array(n).fill(-1),
        e = new Array(2 * m + 10),
        ne = new Array(2 * m + 10),
        w = new Array(2 * m + 10);
  let idx = 0;
  const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
  for (let i = 0; i < m; i++) {
    const [u, v] = await rns();
    add(u - 1, v - 1, i);
    add(v - 1, u - 1, i);
  }
  const vis = new Array(n),
        res = new Array(m).fill(0);
  const bfs = i => {
    const queue = [i];
    for (let u of queue) {
      vis[u] = 1;
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = e[i];
        if (vis[v]) continue;
        vis[v] = 1;
        res[w[i]] = 1;
        queue.push(v);
      }
    }
  };
  for (let i = 0; i < n; i++) {
    if (!vis[i]) bfs(i);
  }
  return res.join('');
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
let inputs = [];
let i = 0;
function read() {
  return inputs[i++];
}
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', async () => {
  const output = await main(read);
  process.stdout.write(output);
});

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const h = new Array(n).fill(-1),
        e = [],
        ne = [],
        w = [];
  const add = (i, j, c) => (e.push(j), w.push(c), ne.push(h[i]), h[i] = ne.length - 1);
  for (let i = 0; i < m; i++) {
    const [u, v] = await rns();
    add(u - 1, v - 1, i);
    add(v - 1, u - 1, i);
  }
  const vis = new Array(n),
        res = new Array(m).fill(0);
  const bfs = i => {
    const queue = [i];
    vis[i] = 1;
    for (let u of queue) {
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = e[i];
        if (vis[v]) continue;
        vis[v] = 1;
        res[w[i]] = 1;
        queue.push(v);
      }
    }
  };
  for (let i = 0; i < n; i++) {
    if (!vis[i]) bfs(i);
  }
  return res.join('');
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
let inputs = [];
let i = 0;
function read() {
  return inputs[i++];
}
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', async () => {
  const output = await main(read);
  process.stdout.write(output);
});

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const h = new Array(n).fill(-1),
        e = new Array(2 * m + 10),
        ne = new Array(2 * m + 10),
        w = new Array(2 * m + 10);
  let idx = 0;
  const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
  for (let i = 0; i < m; i++) {
    const [u, v] = await rns();
    add(u - 1, v - 1, i);
    add(v - 1, u - 1, i);
  }
  const vis = new Array(n),
        res = new Array(m).fill(0);
  const bfs = i => {
    const queue = [i];
    vis[i] = 1;
    for (let u of queue) {
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = e[i];
        if (vis[v]) continue;
        vis[v] = 1;
        res[w[i]] = 1;
        queue.push(v);
      }
    }
  };
  for (let i = 0; i < n; i++) {
    if (!vis[i]) bfs(i);
  }
  return res.join('');
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
let inputs = [];
let i = 0;
function read() {
  return inputs[i++];
}
rl.on('line', line => {
  inputs.push(line);
});
rl.on('close', async () => {
  const output = await main(read);
  process.stdout.write(output);
});

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const h = new Array(n).fill(-1),
        e = new Array(2 * m + 10),
        ne = new Array(2 * m + 10),
        w = new Array(2 * m + 10);
  let idx = 0;
  const add = (i, j, c) => (e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++);
  for (let i = 0; i < m; i++) {
    const [u, v] = await rns();
    add(u - 1, v - 1, i);
    add(v - 1, u - 1, i);
  }
  const vis = new Array(n),
        res = new Array(m).fill(0);
  const bfs = i => {
    const queue = [i];
    vis[i] = 1;
    for (let u of queue) {
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = e[i];
        if (vis[v]) continue;
        vis[v] = 1;
        res[w[i]] = 1;
        queue.push(v);
      }
    }
  };
  for (let i = 0; i < n; i++) {
    if (!vis[i]) bfs(i);
  }
  return res.join('');
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
void async function () {
  let idx = 0;
  const read = () => inputs[idx++];
  const output = await main(read);
  process.stdout.write(output);
}();

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const h = new Array(n).fill(-1),
        e = [],
        ne = [],
        w = [];
  const add = (i, j, c) => (e.push(j), ne.push(h[i]), w.push(c), h[i] = ne.length - 1);
  for (let i = 0; i < m; i++) {
    const [u, v] = await rns();
    add(u - 1, v - 1, i);
  }
  const vis = [],
        res = new Array(m).fill(0);
  const bfs = i => {
    const queue = [i];
    for (let u of queue) {
      vis[u] = 1;
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = e[i];
        if (vis[v]) continue;
        vis[v] = 1;
        res[w[i]] = 1;
        queue.push(v);
      }
    }
  };
  for (let i = 0; i < n; i++) {
    if (!vis[i]) bfs(i);
  }
  return res.join('');
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
const it = rl[Symbol.asyncIterator]();
async function read() {
  return (await it.next()).value;
}
void async function () {
  const output = await main(read);
  process.stdout.write(output);
}();