You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland).You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the obtained garland is nice.A garland is called nice if any two lamps of the same color have distance divisible by three between them. I.e. if the obtained garland is $$$t$$$, then for each $$$i, j$$$ such that $$$t_i = t_j$$$ should be satisfied $$$|i-j|~ mod~ 3 = 0$$$. The value $$$|x|$$$ means absolute value of $$$x$$$, the operation $$$x~ mod~ y$$$ means remainder of $$$x$$$ when divided by $$$y$$$.For example, the following garlands are nice: "RGBRGBRG", "GB", "R", "GRBGRBG", "BRGBRGB". The following garlands are not nice: "RR", "RGBG".Among all ways to recolor the initial garland to make it nice you have to choose one with the minimum number of recolored lamps. If there are multiple optimal solutions, print any of them.

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of lamps. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ characters 'R', 'G' and 'B' — colors of lamps in the garland.

In the first line of the output print one integer $$$r$$$ — the minimum number of recolors needed to obtain a nice garland from the given one. In the second line of the output print one string $$$t$$$ of length $$$n$$$ — a nice garland obtained from the initial one with minimum number of recolors. If there are multiple optimal solutions, print any of them.

var cnt = 0;
var str = "";
var readliner = require('readline');
var rl = readliner.createInterface(process.stdin, process.stdout, null);
rl.on('line', function (cmd) {
                  //console.log('You just typed: '+cmd);
                  cnt++;
                  if (cnt > 1) str = cmd;
              }).on('close', main);

function solve(pat, str, ans, res) {
	//console.log(pat," ",str," ",ans," ",res);
	var N = Math.min(pat.length, str.length);
	var new_ans = 0;
	var new_res = "";
	for (var i=0; i<N; i++) {
		new_res += pat[i];
		if (str[i] !== pat[i])
			new_ans++;
	}
	if (pat.length < str.length)
		for (var i=pat.length; i<str.length; i++) {
			new_res += pat[i%3];
			if (str[i] !== pat[i%3])
				new_ans++;
		}
	//console.log(new_ans," ",new_res);
	if (new_ans < ans) {
		ans = new_ans;
		res.val = new_res;
	}
	return ans;
}

function main() {
	var res = {val:""};
	var ans = solve("RGB", str, 1000000000, res);
	ans = Math.min(ans, solve("RBG",str,ans,res));
	ans = Math.min(ans, solve("BRG",str,ans,res));
	ans = Math.min(ans, solve("BGR",str,ans,res));
	ans = Math.min(ans, solve("GBR",str,ans,res));
	ans = Math.min(ans, solve("GRB",str,ans,res));
	console.log(ans);
	process.stdout.write(res.val);

    //console.log(ans);
    //console.log(Q);

    //var x = 1.2345678;
    //console.log('x = ',Number(x).toFixed(5));

    process.exit(0);
};

//var lines = data.split(/\r?\n/);

function ansa(n,s){

  function permutator(inputArr) {
  var results = [];

  function permute(arr, memo) {
    var cur, memo = memo || [];

    for (var i = 0; i < arr.length; i++) {
      cur = arr.splice(i, 1);
      if (arr.length === 0) {
        results.push(memo.concat(cur));
      }
      permute(arr.slice(), memo.concat(cur));
      arr.splice(i, 0, cur[0]);
    }

    return results;
  }

  return permute(inputArr);
}

  var permuts = permutator(['R','G','B']);
  var ans = s;
  var mn = Infinity;

  for(var i = 0 ; i < permuts.length ; i++){

      var cst = 0;
      for(var j = 0 ; j < n ; j++){
          if(s[j] !== permuts[i][(j+1)%3])cst++;
      }
      if(cst < mn){
        mn = cst;
        ans = "";
        for(var k = 0 ; k < n ; k++)ans = ans + permuts[i][(k+1)%3];
      }
  }

  print(mn);
  print(ans);

}

var n = parseInt(readline());
var str = readline();

ansa(n,str)

var n = +readline();
var s = readline();
var p = ['RGB', 'RBG', 'GRB', 'GBR', 'BRG', 'BGR'];
var min = n + 10;
var por = 0;
var ans = '';
for (var j=0; j<6; j++){
	var min1 = 0;
	for (var i=0; i<n; i++){
		if (s[i] != p[j][i%3]) min1++;
	}
	if (min1<min) {
		min = min1;
		por = j;
	}
}
for (var i=0; i<n; i++){
	ans += p[por][i%3];
}
print (min);
print (ans);

readline();
var input = readline();
var r = [0,0,0];var g = [0,0,0];var b = [0,0,0];

for(var i=0;i<input.length;i++){
var z = i;
if(z>2){z -=(Math.floor(z/3)*3);}
if(input[i]==="R"){r[z]++}
	if(input[i]==="G"){g[z]++}
	   if(input[i]==="B"){b[z]++}
}

var themax = 0;var RGB = [];

for(var s=0;s<3;s++){
var abc = "012".replace(s,"");var x = +abc[0];var y = +abc[1];
var calc = r[s]+g[x]+b[y];
if(themax<=calc){themax=calc;RGB[s]="R";RGB[x]="G";RGB[y]="B";}
calc = r[s]+g[y]+b[x];
if(themax<=calc){themax=calc;RGB[s]="R";RGB[y]="G";RGB[x]="B";}
}

var st="";themax=0;
for (var i = 0; i < input.length; i++) {
if(input[i]!==RGB[x]){themax++}
st+=RGB[x];x++;
if(x==3){x=0}
}

print(themax)
print(st)

function ansa(n,s){

  function FindAllPermutations(str, index, buffer) {
      if (typeof str == "string")
          str = str.split("");
      if (typeof index == "undefined")
          index = 0;
      if (typeof buffer == "undefined")
          buffer = [];
      if (index >= str.length)
          return buffer;
      for (var i = index; i < str.length; i++)
          buffer.push(ToggleLetters(str, index, i));
      return FindAllPermutations(str, index + 1, buffer);
  }

  function ToggleLetters(str, index1, index2) {
      if (index1 != index2) {
          var temp = str[index1];
          str[index1] = str[index2];
          str[index2] = temp;
      }
      return str.join("");
  }

  var permuts = FindAllPermutations("RGB");
  var ans = s;
  var mn = Infinity;

  for(var i = 0 ; i < 6 ; i++){

      var cst = 0;
      for(var j = 0 ; j < n ; j++){
          if(s[j] !== permuts[i][j%3])cst++;
      }
      if(cst < mn){
        mn = cst;
        ans = "";
        for(var k = 0 ; k < n ; k++)ans = ans + permuts[i][k%3];
      }
  }

  print(mn);
  print(ans);

}

var n = parseInt(readline());
var str = readline();

ansa(n,str);

function ansa(n,s){

  function FindAllPermutations(str, index, buffer) {
      if (typeof str == "string")
          str = str.split("");
      if (typeof index == "undefined")
          index = 0;
      if (typeof buffer == "undefined")
          buffer = [];
      if (index >= str.length)
          return buffer;
      for (var i = index; i < str.length; i++)
          buffer.push(ToggleLetters(str, index, i));
      return FindAllPermutations(str, index + 1, buffer);
  }

  function ToggleLetters(str, index1, index2) {
      if (index1 != index2) {
          var temp = str[index1];
          str[index1] = str[index2];
          str[index2] = temp;
      }
      return str.join("");
  }

  var permuts = FindAllPermutations("RGB");
  var ans = "";
  var mn = Infinity;

  for(var i = 0 ; i < permuts.length ; i++){

      var cst = 0;
      for(var j = 0 ; j < n ; j++){
          if(s[j] !== permuts[i][j%3])cst++;
      }
      if(cst < mn){
        mn = cst;
        ans = "";
        for(var k = 0 ; k < n ; k++)ans = ans + permuts[i][k%3];
      }
  }

  print(mn);
  print(ans);

}

var n = parseInt(readline());
var str = readline();

ansa(n,str)

function ansa(n,s){

  function FindAllPermutations(str, index, buffer) {
      if (typeof str == "string")
          str = str.split("");
      if (typeof index == "undefined")
          index = 0;
      if (typeof buffer == "undefined")
          buffer = [];
      if (index >= str.length)
          return buffer;
      for (var i = index; i < str.length; i++)
          buffer.push(ToggleLetters(str, index, i));
      return FindAllPermutations(str, index + 1, buffer);
  }

  function ToggleLetters(str, index1, index2) {
      if (index1 != index2) {
          var temp = str[index1];
          str[index1] = str[index2];
          str[index2] = temp;
      }
      return str.join("");
  }

  var permuts = FindAllPermutations("RGB");
  var ans = s;
  var mn = Infinity;

  for(var i = 0 ; i < permuts.length ; i++){

      var cst = 0;
      for(var j = 0 ; j < n ; j++){
          if(s[j] !== permuts[i][(j+1)%3])cst++;
      }
      if(cst < mn){
        mn = cst;
        ans = "";
        for(var k = 0 ; k < n ; k++)ans = ans + permuts[i][(k+1)%3];
      }
  }

  print(mn);
  print(ans);

}

var n = parseInt(readline());
var str = readline();

ansa(n,str)

function ansa(n,str){

    var cnt = 0;
    var ans = '';

    if(n === 2){
      if(str[0] === str[1]){
        print("1");
        if(str[0] === "R")print("RG");
        else if(str[0] === "G")print("GR");
        else print("BG");
        return;
      }
    }
    if(str[0] === 'R' && str[1] === 'G'){
      var rgb = 'RGB';
      ans = 'RG';
      for(var i = 2 ; i < n ; i++){
        if(rgb[(i)%3] !== str[i]){
          cnt++;
          ans = ans + rgb[(i)%3];
        }
        else ans = ans+str[i];
      }
      print(cnt);
      print(ans);
      return;
    }
    if(str[0] === 'R' && str[1] === 'B'){
      var rbg = 'RBG';
      ans = 'RB';
      for(var i = 2 ; i < n ; i++){
        if(rbg[(i)%3] !== str[i]){
          cnt++;
          ans = ans + rbg[(i)%3];
        }
        else ans = ans+str[i];
      }
      print(cnt);
      print(ans);
      return;
    }
    if(str[0] === 'B' && str[1] === 'R'){
      var brg = 'BRG';
      ans = 'BR';
      for(var i = 2 ; i < n ; i++){
        if(brg[(i)%3] !== str[i]){
          cnt++;
          ans = ans + brg[(i)%3];
        }
        else ans = ans+str[i];
      }
      print(cnt);
      print(ans);
      return;
    }
    if(str[0] === 'B' && str[1] === 'G'){
      var bgr = 'BGR';
      ans = 'BG';
      for(var i = 2 ; i < n ; i++){
        if(bgr[(i)%3] !== str[i]){
          cnt++;
          ans = ans + bgr[(i)%3];
        }
        else ans = ans+str[i];
      }
      print(cnt);
      print(ans);
      return;
    }
    if(str[0] === 'G' && str[1] === 'R'){
      var grb = 'GRB';
      ans = 'GR';
      for(var i = 2 ; i < n ; i++){
        if(grb[(i)%3] !== str[i]){
          cnt++;
          ans = ans + grb[(i)%3];
        }
        else ans = ans+str[i];
      }
      print(cnt);
      print(ans);
      return;
    }
    if(str[0] === 'G' && str[1] === 'B'){
      var gbr = 'GBR';
      ans = 'GB';
      for(var i = 2 ; i < n ; i++){
        if(gbr[(i)%3] !== str[i]){
          cnt++;
          ans = ans + gbr[(i)%3];
        }
        else ans = ans+str[i];
      }
      print(cnt);
      print(ans);
      return;
    }
    if(str[0] === 'G' && str[1] === 'G'){
      var gbr = 'GBR';
      ans = 'G';
      for(var i = 1 ; i < n ; i++){
        if(gbr[(i)%3] !== str[i]){
          cnt++;
          ans = ans + gbr[(i)%3];
        }
        else ans = ans+str[i];
      }
      print(cnt);
      print(ans);
      return;
    }
    if(str[0] === 'R' && str[1] === 'R'){
      var rgb = 'RGB';
      ans = 'R';
      for(var i = 1 ; i < n ; i++){
        if(rgb[(i)%3] !== str[i]){
          cnt++;
          ans = ans + rgb[(i)%3];
        }
        else ans = ans+str[i];
      }
      print(cnt);
      print(ans);
      return;
    };
    if(str[0] === 'B' && str[1] === 'B'){
      var bgr = 'BGR';
      ans = 'B';
      for(var i = 1 ; i < n ; i++){
        if(bgr[(i)%3] !== str[i]){
          cnt++;
          ans = ans + bgr[(i)%3];
        }
        else ans = ans+str[i];
      }
      print(cnt);
      print(ans);
      return;
    };

}

var n = parseInt(readline());
var str = readline();

ansa(n,str);

function ansa(n,s){

  function FindAllPermutations(str, index, buffer) {
      if (typeof str == "string")
          str = str.split("");
      if (typeof index == "undefined")
          index = 0;
      if (typeof buffer == "undefined")
          buffer = [];
      if (index >= str.length)
          return buffer;
      for (var i = index; i < str.length; i++)
          buffer.push(ToggleLetters(str, index, i));
      return FindAllPermutations(str, index + 1, buffer);
  }

  function ToggleLetters(str, index1, index2) {
      if (index1 != index2) {
          var temp = str[index1];
          str[index1] = str[index2];
          str[index2] = temp;
      }
      return str.join("");
  }

  var permuts = FindAllPermutations("RGB");
  var ans = s;
  var mn = Infinity;

  for(var i = 0 ; i < permuts.length ; i++){

      var cst = 0;
      for(var j = 0 ; j < n ; j++){
          if(s[j] !== permuts[i][j%3])cst++;
      }
      if(cst < mn){
        mn = cst;
        ans = "";
        for(var k = 0 ; k < n ; k++)ans = ans + permuts[i][k%3];
      }
  }

  print(mn);
  print(ans);

}

var n = parseInt(readline());
var str = readline();

ansa(n,str)


Hongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries.The world can be modeled as an undirected graph with n nodes and m edges. k of the nodes are home to the governments of the k countries that make up the world.There is at most one edge connecting any two nodes and no edge connects a node to itself. Furthermore, for any two nodes corresponding to governments, there is no path between those two nodes. Any graph that satisfies all of these conditions is stable.Hongcow wants to add as many edges as possible to the graph while keeping it stable. Determine the maximum number of edges Hongcow can add.

The first line of input will contain three integers n, m and k (1 ≤ n ≤ 1 000, 0 ≤ m ≤ 100 000, 1 ≤ k ≤ n) — the number of vertices and edges in the graph, and the number of vertices that are homes of the government.  The next line of input will contain k integers c1, c2, ..., ck (1 ≤ ci ≤ n). These integers will be pairwise distinct and denote the nodes that are home to the governments in this world. The following m lines of input will contain two integers ui and vi (1 ≤ ui, vi ≤ n). This denotes an undirected edge between nodes ui and vi. It is guaranteed that the graph described by the input is stable.

Output a single integer, the maximum number of edges Hongcow can add to the graph while keeping it stable.

NoteFor the first sample test, the graph looks like this:    Vertices 1 and 3 are special. The optimal solution is to connect vertex 4 to vertices 1 and 2. This adds a total of 2 edges. We cannot add any more edges, since vertices 1 and 3 cannot have any path between them.For the second sample test, the graph looks like this:    We cannot add any more edges to this graph. Note that we are not allowed to add self-loops, and the graph must be simple.

var edgesInClique = function ( verticesCount ) {
 return verticesCount * (verticesCount  - 1) / 2;
};

var getComponent = function ( graph, anyComponentVertex ) {
  var component,
    visited,
    stack,
    visitVertex,
    i;
  component = { verticies: [], edgesCount: 0 };
  visited = [];
  stack = [];
  stack.push( anyComponentVertex );
  while( stack.length > 0 ) {
    visitVertex = stack.pop();
    if ( !visited[ visitVertex ] ) {
      component.verticies.push( visitVertex );
      for ( i = 0; i < graph[ visitVertex ].length; ++i ) {
        /*
          I will count all edges twice.
        */
        ++component.edgesCount;
        stack.push( graph[ visitVertex ][ i ] );
      }
      visited[ visitVertex ] = true;
    }
  }
  component.edgesCount /= 2;
  return component;
};

var howManyCanAdd = function ( graph, capitals ) {
  var i,
    j,
    result,
    capital,
    visited,
    component,
    largestComponentEdgesCount;
  result = 0;
  visited = new Array( graph.length );
  visited.fill( false );
  verticiesCount = new Array( graph.length );
  for ( i = 0; i < capitals.length; ++i ) {
    capital = capitals[ i ];
    component = getComponent( graph, capital );
    for ( j = 0; j < component.verticies.length; ++j ) {
      visited[ component.verticies[ j ] ] = true;
    }
    verticiesCount[ capital ] = component.verticies.length;
    result += edgesInClique( component.verticies.length ) - component.edgesCount;
  }
  debugger;
  verticiesCount.sort( (a,b) => b - a );
  largestComponentVerticiesCount = verticiesCount[ 0 ];
  for ( i = 0; i < graph.length; ++i ) {
    if ( !visited[ i ] ) {
      component = getComponent( graph, i );
      for ( j = 0; j < component.verticies.length; ++j ) {
        visited[ component.verticies[ j ] ] = true;
      }
      result += edgesInClique( component.verticies.length ) - component.edgesCount;
      result += largestComponentVerticiesCount * component.verticies.length;
      largestComponentVerticiesCount += component.verticies.length;
    }
  }
  return result;
};

var parseNumber = i => parseInt( i, 10 );
var input = readline().split( " " ).map( parseNumber  );
var n = input[ 0 ];
var m = input[ 1 ];
var k = input[ 2 ];
var capitals = readline().split( " " ).map( function ( i ) { return parseInt( i, 10) -1; } );
var graph = new Array( n );
var i;
for ( i = 0; i < n; ++i ) {
  graph[ i ] = [];
}
for ( i = 0; i < m; ++i ) {
  var edge = readline().split( " " ).map( parseNumber );
  graph[ edge[ 0 ] - 1 ].push( edge[ 1 ] - 1 );
  graph[ edge[ 1 ] - 1 ].push( edge[ 0 ] - 1 );
}
print( howManyCanAdd( graph, capitals ) );

var edgesInClique = function ( verticesCount ) {
 return verticesCount * (verticesCount  - 1) / 2;
};

var getComponent = function ( graph, anyComponentVertex ) {
  var component,
    visited,
    stack,
    visitVertex,
    i;
  debugger;
  component = { verticies: [], edgesCount: 0 };
  visited = [];
  stack = [];
  stack.push( anyComponentVertex );
  while( stack.length > 0 ) {
    visitVertex = stack.pop();
    if ( !visited[ visitVertex ] ) {
      component.verticies.push( visitVertex );
      for ( i = 0; i < graph[ visitVertex ].length; ++i ) {
        /*
          I will count all edges twice.
        */
        ++component.edgesCount;
        stack.push( graph[ visitVertex ][ i ] );
      }
      visited[ visitVertex ] = true;
    }
  }
  component.edgesCount /= 2;
  return component;
};

var howManyCanAdd = function ( graph, capitals ) {
  var i,
    j,
    result,
    capital,
    visited,
    component,
    largestComponentEdgesCount;
  result = 0;
  visited = new Array( graph.length );
  visited.fill( false );
  verticiesCount = new Array( graph.length );
  for ( i = 0; i < capitals.length; ++i ) {
    capital = capitals[ i ];
    component = getComponent( graph, capital );
    for ( j = 0; j < component.verticies.length; ++j ) {
      visited[ component.verticies[ j ] ] = true;
    }
    verticiesCount[ capital ] = component.verticies.length;
    result += edgesInClique( component.verticies.length ) - component.edgesCount;
  }
  verticiesCount.sort( (a,b) => b - a );
  largestComponentVerticiesCount = verticiesCount[ 0 ];
  for ( i = 0; i < graph.length; ++i ) {
    if ( !visited[ i ] ) {
      component = getComponent( graph, i );
      result += edgesInClique( component.verticies.length ) - component.edgesCount;
      largestComponentVerticiesCount *=  component.verticies.length;
      result += largestComponentVerticiesCount
    }
  }
  return result;
};

var parseNumber = i => parseInt( i, 10 );
var input = readline().split( " " ).map( parseNumber  );
var n = input[ 0 ];
var m = input[ 1 ];
var k = input[ 2 ];
var capitals = readline().split( " " ).map( function ( i ) { return parseInt( i, 10) -1; } );
var graph = new Array( n );
var i;
for ( i = 0; i < n; ++i ) {
  graph[ i ] = [];
}
for ( i = 0; i < m; ++i ) {
  var edge = readline().split( " " ).map( parseNumber );
  graph[ edge[ 0 ] - 1 ].push( edge[ 1 ] - 1 );
  graph[ edge[ 1 ] - 1 ].push( edge[ 0 ] - 1 );
}
print( howManyCanAdd( graph, capitals ) );


You and your friend are playing the game Mortal Kombat XI. You are trying to pass a challenge tower. There are $$$n$$$ bosses in this tower, numbered from $$$1$$$ to $$$n$$$. The type of the $$$i$$$-th boss is $$$a_i$$$. If the $$$i$$$-th boss is easy then its type is $$$a_i = 0$$$, otherwise this boss is hard and its type is $$$a_i = 1$$$.During one session, either you or your friend can kill one or two bosses (neither you nor your friend can skip the session, so the minimum number of bosses killed during one session is at least one). After your friend session, your session begins, then again your friend session begins, your session begins, and so on. The first session is your friend's session.Your friend needs to get good because he can't actually kill hard bosses. To kill them, he uses skip points. One skip point can be used to kill one hard boss.Your task is to find the minimum number of skip points your friend needs to use so you and your friend kill all $$$n$$$ bosses in the given order.For example: suppose $$$n = 8$$$, $$$a = [1, 0, 1, 1, 0, 1, 1, 1]$$$. Then the best course of action is the following:  your friend kills two first bosses, using one skip point for the first boss;  you kill the third and the fourth bosses;  your friend kills the fifth boss;  you kill the sixth and the seventh bosses;  your friend kills the last boss, using one skip point, so the tower is completed using two skip points. You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of bosses. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 1$$$), where $$$a_i$$$ is the type of the $$$i$$$-th boss. It is guaranteed that the sum of $$$n$$$ does not exceed $$$2 \cdot 10^5$$$ ($$$\sum n \le 2 \cdot 10^5$$$).

For each test case, print the answer: the minimum number of skip points your friend needs to use so you and your friend kill all $$$n$$$ bosses in the given order.

process.stdin.resume();
process.stdin.setEncoding("utf-8");
let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => line.trim());

  main();
});

function main() {
  const t = parseInt(readLine());
  for (let i = 0; i < t; i++) {
    let unused = readLine();
    let bossArr = readLine()
      .split(" ")
      .map((el) => {
        return { a: parseInt(el), p: "" };
      });

    // set first to friend
    bossArr[0].p = "f";

    // set friend everywhere where boss is easy:
    bossArr = bossArr.map((el) => {
      if (el.a === 0) el.p = "f";

      return el;
    });

    // set me everywhere in 2 tiles if I can:

    let meCount = 0;
    for (let i = 0; i < bossArr.length; i++) {
      if (bossArr[i].p == "f") {
        meCount = 0;
        continue;
      } else if (meCount < 2) {
        bossArr[i].p = "m";
        meCount++;
      } else if (meCount >= 2) {
        bossArr[i].p = "f";
        meCount = 0;
      }
    }

    let res = bossArr.reduce(
      (acc, cur) => acc + (cur.a == 1 && cur.p == "f" ? 1 : 0),
      0
    );

    console.log(res);
  }
}

"use strict";
var input = '';
var inputResolve;
var inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => {
    inputResolve();
});
(async () => {
    var time = Date.now();
    await inputPromise;
    var inputs = input.split(/\r?\n/);
    var t = +inputs[0];
    for (let i = 0; i < t; i++) {
        var n = +inputs[i * 2 + 1];
        var a = inputs[i * 2 + 2].split(' ').map(v => +v);
        var b = [a[0], a[0] + a[1]];
        var c = [1e5, b[0]];
        for (let i = 2; i < n; i++) {
            b[i] = Math.min(a[i] + c[i - 1], a[i] + a[i - 1] + c[i - 2]);
            c[i] = Math.min(b[i - 1], b[i - 2]);
        }
        console.log(Math.min(b[n - 1], c[n - 1]));
    }
})();
Object.defineProperty(Object.prototype, '$k', {
    value: function () { return Object.keys(this); }
});
Object.defineProperty(Object.prototype, '$v', {
    value: function () { return Object.values(this); }
});
Object.defineProperty(Object.prototype, '$kv', {
    value: function () { return Object.entries(this); }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0); };
Array.prototype.uniq = function (fn) {
    var set = new Set();
    return this.filter(v => {
        var newValue = !set.has(fn ? fn(v) : v);
        set.add(fn ? fn(v) : v);
        return newValue;
    });
};
Array.prototype.toObj = function (fn) {
    return this.map(v => fn(v)).reduce((p, v) => {
        p[v[0]] = v[1];
        return p;
    }, {});
};

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();
    });

    C();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function A(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [x, y, k] = ti(readline().split(' '));

        let res = Math.ceil((k + (k*y) - 1) / (x-1));
        console.log(res + k);
    }
}

function C(){
    try{
        let t = pi(readline());
        while(t > 0){
            t--;
            let n = pi(readline());
            let a = ti(readline().split(' '));
            if(n === 0){
                console.log(0);
                continue;
            }

            let dp = new Array(n);
            for(let j = 0; j < n; j++){
                dp[j] = new Array(2);
                dp[j].fill(-1);
            }

            for(let i = 0; i < n; i++){
                if(i >= 2){
                    dp[i][0] = Math.min(dp[i-1][1]+a[i], dp[i-2][1]+a[i]+a[i-1]);
                    dp[i][1] = Math.min(dp[i-1][0], dp[i-2][0]);
                }else{
                    if(i === 0){
                        dp[i][0] = a[i];
                        dp[i][1] = a[i];
                    }else{
                        dp[i][0] = a[i] + a[i-1];
                        dp[i][1] = dp[i-1][0];
                    }
                }
            }

            //console.log(dp);
            console.log(Math.min(dp[n-1][0], dp[n-1][1]));

            let solve = (i, turn) => {
                console.log(i);
                if(i >= n)
                    return 0;

                if(i === n-1){
                    if(turn === 0)
                        return dp[i][turn] = a[i];
                    else
                        return dp[i][turn] = 0;
                }

                if(dp[i][turn] !== -1)
                    return dp[i][turn];

                if(turn === 0){
                    return dp[i][turn] = Math.min(a[i] + solve(i+1, 1), a[i]+a[i+1]+solve(i+2, 1));
                }else{
                    return dp[i][turn] = Math.min(solve(i+1, 0), solve(i+2, 0));
                }
            }

            //console.log(solve(0, 0));
        }
    }catch(e){
        console.log(e);
    }
}

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();
    });

    C();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function A(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [x, y, k] = ti(readline().split(' '));

        let res = Math.ceil((k + (k*y) - 1) / (x-1));
        console.log(res + k);
    }
}

function C(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let n = pi(readline());
        let a = ti(readline().split(' '));

        let count = 0;
        let i = 0;
        let turn = 0;
        while(i < n){
            if(turn === 0){
                if(a[i] === 1){
                    count += 1;
                    i += 1;
                }

                if(i < n && a[i] === 0){
                    i += 1;
                }
                turn = 1;
            }else{
                i += 1;
                if(i < n && a[i] === 1)
                    i += 1;

                turn = 0;
            }
        }
        console.log(count);
    }
}

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();
    });

    C();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function A(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [x, y, k] = ti(readline().split(' '));

        let res = Math.ceil((k + (k*y) - 1) / (x-1));
        console.log(res + k);
    }
}

function C(){
    try{
        let t = pi(readline());
        while(t > 0){
            t--;
            let n = pi(readline());
            let a = ti(readline().split(' '));
            if(n === 0){
                console.log(0);
                continue;
            }

            let dp = new Array(n);
            for(let j = 0; j < n; j++){
                dp[j] = new Array(2);
                dp[j].fill(-1);
            }

            let solve = (i, turn) => {
                if(i >= n)
                    return 0;

                if(i === n-1){
                    if(turn === 0)
                        return dp[i][turn] = a[i];
                    else
                        return dp[i][turn] = 0;
                }

                if(dp[i][turn] !== -1)
                    return dp[i][turn];

                if(turn === 0){
                    return dp[i][turn] = Math.min(a[i] + solve(i+1, 1), a[i]+a[i+1]+solve(i+2, 1));
                }else{
                    return dp[i][turn] = Math.min(solve(i+1, 0), solve(i+2, 0));
                }
            }

            console.log(solve(0, 0));
        }
    }catch(e){
        console.log(e);
    }
}


There is a chessboard of size $$$n$$$ by $$$n$$$. The square in the $$$i$$$-th row from top and $$$j$$$-th column from the left is labelled $$$(i,j)$$$.Currently, Gregor has some pawns in the $$$n$$$-th row. There are also enemy pawns in the $$$1$$$-st row. On one turn, Gregor moves one of his pawns. A pawn can move one square up (from $$$(i,j)$$$ to $$$(i-1,j)$$$) if there is no pawn in the destination square. Additionally, a pawn can move one square diagonally up (from $$$(i,j)$$$ to either $$$(i-1,j-1)$$$ or $$$(i-1,j+1)$$$) if and only if there is an enemy pawn in that square. The enemy pawn is also removed.Gregor wants to know what is the maximum number of his pawns that can reach row $$$1$$$?Note that only Gregor takes turns in this game, and the enemy pawns never move. Also, when Gregor's pawn reaches row $$$1$$$, it is stuck and cannot make any further moves.

The first line of the input contains one integer $$$t$$$ ($$$1\le t\le 2\cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case consists of three lines. The first line contains a single integer $$$n$$$ ($$$2\le n\le 2\cdot{10}^{5}$$$) — the size of the chessboard. The second line consists of a string of binary digits of length $$$n$$$, where a $$$1$$$ in the $$$i$$$-th position corresponds to an enemy pawn in the $$$i$$$-th cell from the left, and $$$0$$$ corresponds to an empty cell. The third line consists of a string of binary digits of length $$$n$$$, where a $$$1$$$ in the $$$i$$$-th position corresponds to a Gregor's pawn in the $$$i$$$-th cell from the left, and $$$0$$$ corresponds to an empty cell. It is guaranteed that the sum of $$$n$$$ across all test cases is less than $$$2\cdot{10}^{5}$$$.

For each test case, print one integer: the maximum number of Gregor's pawns which can reach the $$$1$$$-st row.

NoteIn the first example, Gregor can simply advance all $$$3$$$ of his pawns forward. Thus, the answer is $$$3$$$.In the second example, Gregor can guarantee that all $$$4$$$ of his pawns reach the enemy row, by following the colored paths as demonstrated in the diagram below. Remember, only Gregor takes turns in this "game"!  In the third example, Gregor's only pawn is stuck behind the enemy pawn, and cannot reach the end.In the fourth example, Gregor has no pawns, so the answer is clearly $$$0$$$.

'use strict';

function solve(n, a) {
  const c = a.map(s => s.split('').map(Number));
  const dp = new Array(n).fill(0);
  for (let i = 0; i < n; i++) {
    var _dp;
    if (c[1][i] === 0) dp[i] = (_dp = dp[i - 1]) !== null && _dp !== void 0 ? _dp : 0;else {
      var _dp2, _dp4;
      if (c[0][i] === 0 || c[0][i - 1] === 1) dp[i] = ((_dp2 = dp[i - 1]) !== null && _dp2 !== void 0 ? _dp2 : 0) + 1;else if (c[0][i + 1] === 1) {
        var _dp3;
        dp[i] = ((_dp3 = dp[i - 1]) !== null && _dp3 !== void 0 ? _dp3 : 0) + 1;
        c[0][i + 1] = 2;
      } else dp[i] = (_dp4 = dp[i - 1]) !== null && _dp4 !== void 0 ? _dp4 : 0;
    }
  }
  return dp[n - 1];
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = Number(await read());
      const a = [];
      let tmp = 2;
      while (tmp--) {
        a.push(await read());
      }
      res[i] = solve(n, a);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});

//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 t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var s = nextCharArray();
		var v = nextCharArray();
		var output = 0;
		for(var i = 0; i < N; i++){
			if(v[i] == "1"){
				if(s[i] == "0"){
					output++;
					continue;
				}
				if(i > 0){
					if(s[i - 1] == "1"){
						s[i - 1] = "0";
						output++;
						continue;
					}
				}
				if(i < N - 1){
					if(s[i + 1] == "1"){
						s[i + 1] = "0";
						output++;
						continue;
					}
				}

			}
		}
		myout(output);
	}
}

'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++];
}

function printline(s, end = '\n') {
  process.stdout.write(s + end);
}

function main() {
  let t = parseInt(readline(), 10);
  while(t--) {
    const n = parseInt(readline(), 10);
    let enemy = readline().split('');
    const paws = readline();

    let ans = 0;

    for (let i = 0; i < n; ++i) {
      if (paws[i] === '1') {
        if (enemy[i] === '0') {
          ans++;
          enemy[i] = '2';
        } else {
          if (i > 0 && enemy[i-1] === '1') {
            ans++;
            enemy[i-1] = '2';
          } else if (i < n && enemy[i+1] === '1') {
            ans++;
            enemy[i+1] = '2';
          }
        }
      }
    }

    printline(ans);
  }
}

// run: cat input.txt | node B.js

'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++];
}

var maxN = 2 * 1e5 + 10
var mod = 1e9 + 7

function main() {
  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    var a = readline().split('').map((x, iii) => {
      return parseInt(x)
    })
    var b = readline().split('').map((x, iii) => {
      return parseInt(x)
    })
    var res = 0
    for (let j = 0; j < n; j++) {
      if (b[j] === 1 && a[j] === 0 ) {
        res++
        continue
      }

      if (b[j] === 1 && a[j - 1] === 1 && j - 1 >= 0) {
        res++
        a[j - 1] = 0
        continue
      }
      if (b[j] === 1 && a[j + 1] === 1 && j + 1 < n) {
        res++
        a[j + 1] = 0
        continue
      }
    }

    console.log(res)
  })
  // var res = new Array(n)
}

function plus(a, b, res) {
// console.log(a, b, res)
  if (a === 0) return res

  return plus(a < 0 ? a + 1 : a - 1, b, a < 0 ? res - b : res + b)
}

var fs = require("fs");
var stdinBuffer = fs.readFileSync(0); // STDIN_FILENO = 0

const lines = stdinBuffer.toString().match(/[^\r\n]+/g).slice(1);

const examples = [];

for(let i = 0; i < lines.length; i+= 3) {
    examples.push([
        lines[i+1].split('').map(letter => letter === '1'),
        lines[i+2].split('').map(letter => letter === '1'),
    ]);
}

const solver = (arr) => {
    let currentResult = 0;
    arr[0].forEach((top, index) => {
        // console.log(currentResult, index)
        const bottom = Boolean(arr[1][index]);
        const bottomRight = Boolean(arr[1][index + 1]);

        if ((top && arr[1][index - 1])) {
            currentResult++;
            arr[1][index - 1] = false;
            return;
        }
        if ((top === false && bottom)) {
            currentResult++;
            arr[1][index] = false;
            return;
        }
        if ((top && bottomRight)) {
            currentResult++;
            arr[1][index + 1] = false;
        }
    })
    return currentResult
};

// console.log(examples)

for(let example of examples) {
    console.log(solver(example))
}

var testCasesCount = readline();

for(var i=0; i<testCasesCount; i++){

    var noOfPawnsCanReachEndline = 0;

    var chesssize = readline();

    var enemyArray = readline().split("");
    var playerArray = readline().split("");

    for(var playerPawn =0; playerPawn<playerArray.length; playerPawn++){
        if(playerArray[playerPawn] === '1'){ // if player pawn exists
            if(enemyArray[playerPawn] === '0'){ // if enemy player doest not exist
                noOfPawnsCanReachEndline ++;
            }else if(enemyArray[playerPawn-1] === '1'){ // if enemy player exist diagonally
                noOfPawnsCanReachEndline ++;
                enemyArray[playerPawn-1] = 0;
            }else if(enemyArray[playerPawn+1] === '1'){ // if enemy player exist diagonally
                noOfPawnsCanReachEndline ++;
                enemyArray[playerPawn+1] = 0;
            }
        }
    }

    print(noOfPawnsCanReachEndline);

}

function solve(n, gregor, me) {
  var taken = new Array(n).fill(0);
  var score = 0;

  for (var i = 0; i < n; i++) {
    if (gregor[i] === "1") taken[i] = 1;
  }

  for (var _i = 0; _i < n; _i++) {
    if (me[_i] !== "1") continue;

    if (_i - 1 >= 0 && taken[_i - 1] === 1) {
      score++;
      taken[_i - 1] = 2;
    } else if (taken[_i] === 0) {
      taken[_i] = 2;
      score++;
    } else if (_i + 1 < n && taken[_i + 1] === 1) {
      score++;
      taken[_i + 1] = 2;
    }
  }

  return score;
}

var t = parseInt(readline());

for (var i = 0; i < t; i++) {
  n = parseInt(readline());
  var gregor = readline();
  var me = readline();
  print(solve(n, gregor, me));
}

var t = readline()

while (t--) {
    solve();
}

function solve() {
    var n = readline();
    var s = readline();
    var st2 = readline();
    var st = s.split('');
    var cont = 0;

    for (var i = 0; i < n; i++){
        if (st2[i] === '1') {
            if (st[i] === '0') {
                cont++;
                st[i] = '3';
                continue;
            }
            if (i > 0 && st[i - 1] === '1') {
                st[i - 1] = '3';
                cont++;
                continue;
            }
            if (i < n - 1 && st[i + 1] === '1') {
                st[i + 1] = '3';
                cont++;
            }
        }
    }
    write(cont + '\n');
}

const main = () => {

	var t = readInt();
	var allans = [];
	while (t-- > 0) {
		var n = readInt();
		var enemy = readline().split("").map(zzzz => parseInt(zzzz));
		var gregor = readline().split("").map(zzzz => parseInt(zzzz));
		var cnt = 0;
		for (var i = 0; i < n; i++) {
			if (gregor[i] === 0)
				continue;
			if (i - 1 >= 0 && enemy[i - 1] === 1) { // take pawn on left
				cnt++;
				continue;
			}
			if (enemy[i] === 0) { //go straight
				cnt++;
				continue;
			}
			if (i + 1 < n && enemy[i + 1] === 1) { //take pawn on right
				cnt++
				enemy[i + 1] = -1; // can't use this grid anymore
				continue;
			}
		}
		allans.push(cnt);
	}
	multiLineArrayPrint(allans);

	return;
}

const readInt = () => parseInt(readline());
const readString = () => readline();
const readIntArr = () => readline().split(" ").map(zzzz => parseInt(zzzz));
const parseLong = (string) => { // javascript's largest long is < (1<<62)
	var n = string.length;
	var res = 0;
	for (var i = 0; i < n; i++) {
		res *= 10;
		res += parseInt(string[i]);
	}
	return res;
}
const readLong = () => parseLong(readLong());
const readLongArr = () => readline().split(" ").map(zzzz => parseLong(zzzz));
const oneLineArrayPrint = (arr) => print(arr.map(zzzz => zzzz.toString()).join(' '));
const multiLineArrayPrint = (arr) => print(arr.map(zzzz => zzzz.toString()).join('\n'));
const multiLineArrayOfArraysPrint = (arr) => print(arr.map(yyyy => yyyy.map(zzzz => zzzz.toString()).join(' ')).join('\n'));
const makeArr = (defaultVal, dimensionsArr) => {
	var n = dimensionsArr.length;
	if (n === 1) return Array(dimensionsArr[0]).fill(defaultVal);
	else {
		var temp = [];
		for (var i = 0; i < dimensionsArr[0]; i++)
			temp.push(makeArr(defaultVal, dimensionsArr.slice(1)));
		return temp;
	}
}

for (_ = 0; _ < 1; _++) {
	main();
}

// newline for testing
 //newline for testing
// codeforces js cannot use "let" keyword. use "var" instead
// codeforces js cannot destructure arrays

'use strict';

function solve(n, a) {
  const c = a.map(s => s.split('').map(Number));
  const dp = new Array(n).fill(0);
  for (let i = 0; i < n; i++) {
    var _dp;
    if (c[1][i] === 0) dp[i] = (_dp = dp[i - 1]) !== null && _dp !== void 0 ? _dp : 0;else {
      var _dp2;
      if (c[0][i] === 0 || c[0][i - 1] === 1) dp[i] = ((_dp2 = dp[i - 1]) !== null && _dp2 !== void 0 ? _dp2 : 0) + 1;else if (c[0][i + 1] === 1) {
        var _dp3;
        dp[i] = ((_dp3 = dp[i - 1]) !== null && _dp3 !== void 0 ? _dp3 : 0) + 1;
        c[0][i + 1] = 2;
      }
    }
  }
  return dp[n - 1];
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = Number(await read());
      const a = [];
      let tmp = 2;
      while (tmp--) {
        a.push(await read());
      }
      res[i] = solve(n, a);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});

//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 t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var s = nextCharArray();
		var v = nextCharArray();
		var output = 0;
		for(var i = 0; i < N; i++){
			if(v[i] == "1"){
				if(s[i] == "0"){
					output++;
					continue;
				}
				if(i < N - 1){
					if(s[i + 1] == "1"){
						s[i + 1] = "0";
						output++;
						continue;
					}
				}
				if(i > 0){
					if(s[i - 1] == "1"){
						s[i - 1] = "0";
						output++;
						continue;
					}
				}
			}
		}
		myout(output);
	}
}

'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++];
}

var maxN = 2 * 1e5 + 10
var mod = 1e9 + 7

function main() {
  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    var a = readline().split('').map((x, iii) => {
      return parseInt(x)
    })
    var b = readline().split('').map((x, iii) => {
      return parseInt(x)
    })
    var res = 0
    for (let j = 0; j < n; j++) {
      if (b[j] === 1 && a[j] === 0 ) {
        res++
        continue
      }

      if (b[j] === 1 && a[j + 1] === 1 && j + 1 < n) {
        res++
        a[j + 1] = 0
        continue
      }
      if (b[j] === 1 && a[j - 1] === 1 && j - 1 >= 0) {
        res++
        a[j - 1] = 0
        continue
      }
    }

    console.log(res)
  })
  // var res = new Array(n)
}

function plus(a, b, res) {
// console.log(a, b, res)
  if (a === 0) return res

  return plus(a < 0 ? a + 1 : a - 1, b, a < 0 ? res - b : res + b)
}

var testCasesCount = readline();

for(var i=0; i<testCasesCount; i++){

    var noOfPawnsCanReachEndline = 0;

    var chesssize = readline();

    var enemyArray = readline().split("");
    var playerArray = readline().split("");

    for(var playerPawn =0; playerPawn<playerArray.length; playerPawn++){
        if(playerArray[playerPawn] === '1'){ // if player pawn exists
            if(enemyArray[playerPawn] === '0'){ // if enemy player doest not exist
                noOfPawnsCanReachEndline ++;
            }else if(enemyArray[playerPawn+1] === '1'){ // if enemy player exist diagonally
                noOfPawnsCanReachEndline ++;
                enemyArray[playerPawn+1] = 0;
            }else if(enemyArray[playerPawn-1] === '1'){ // if enemy player exist diagonally
                noOfPawnsCanReachEndline ++;
                enemyArray[playerPawn-1] = 0;
            }
        }
    }

    print(noOfPawnsCanReachEndline);

}

var testCasesCount = readline();

var noOfPawnsCanReachEndline = 0;

for(var i=0; i<testCasesCount; i++){

    var chesssize = readline();

    var enemyArray = readline().split("");
    var playerArray = readline().split("");

    for(var playerPawn =0; playerPawn<playerArray.length; playerPawn++){
        if(playerArray[playerPawn] === '1'){ // if player pawn exists
            if(enemyArray[playerPawn] === '0'){ // if enemy player doest not exist
                noOfPawnsCanReachEndline ++;
            }else if(enemyArray[playerPawn+1] === '1'){ // if enemy player exist diagonally
                noOfPawnsCanReachEndline ++;
                enemyArray[playerPawn+1] = 0;
            }
        }
    }

    print(noOfPawnsCanReachEndline);

}

var testCasesCount = readline();

var noOfPawnsCanReachEndline = 0;

for(var i=0; i<testCasesCount; i++){

    var chesssize = readline();

    var enemyArray = readline().split("");
    var playerArray = readline().split("");

    for(var playerPawn =0; playerPawn<playerArray.length; playerPawn++){
        if(playerArray[playerPawn] === '1'){ // if player pawn exists
            if(enemyArray[playerPawn] === '0'){ // if enemy player doest not exist
                noOfPawnsCanReachEndline ++;
            }else if(enemyArray[playerPawn+1] === '1'){ // if enemy player exist diagonally
                noOfPawnsCanReachEndline ++;
                enemyArray[playerPawn+1] = 0;
            }
        }
    }

}

var testCasesCount = readline();

var noOfPawnsCanReachEndline = 0;

for(var i=0; i<testCasesCount; i++){

    var chesssize = readline();

    var enemyArray = readline().split("");
    var playerArray = readline().split("");

    for(var playerPawn =0; playerPawn<playerArray.length; playerPawn++){
        if(playerArray[playerPawn] === 1){ // if player pawn exists
            if(enemyArray[playerPawn] === 0){ // if enemy player doest not exist
                noOfPawnsCanReachEndline ++;
            }else if(enemyArray[playerPawn+1] === 1){ // if enemy player exist diagonally
                noOfPawnsCanReachEndline ++;
                enemyArray[playerPawn+1] = 0;
            }
        }
    }

    print(noOfPawnsCanReachEndline);

}

var testCasesCount = readline();

var noOfPawnsCanReachEndline = 0;

for(var i=0; i<testCasesCount; i++){

    var chesssize = readline();

    var enemyArray = readline().split("");
    var playerArray = readline().split("");

    for(var playerPawn =0; playerPawn<playerArray.length; playerPawn++){
        if(playerArray[playerPawn] === 1){ // if player pawn exists
            if(enemyArray[playerPawn] === 0){ // if enemy player doest not exist
                noOfPawnsCanReachEndline ++;
            }else if(enemyArray[playerPawn+1] === 1){ // if enemy player exist diagonally
                noOfPawnsCanReachEndline ++;
                enemyArray[playerPawn+1] = 0;
            }
        }
    }

}

function solve(n, gregor, me) {
  var taken = new Array(n).fill(false);
  var score = 0;

  for (var i = 0; i < n; i++) {
    if (gregor[i] === "1") taken[i] = true;
  }

  for (var _i = 0; _i < n; _i++) {
    if (me[_i] !== "1") continue;

    if (_i - 1 >= 0 && taken[_i - 1]) {
      score++;
      taken[_i - 1] = true;
    } else if (!taken[_i]) {
      taken[_i] = true;
      score++;
    } else if (_i + 1 < n && taken[_i + 1]) {
      score++;
      taken[_i + 1] = true;
    }
  }

  return score;
}

var t = parseInt(readline());

for (var i = 0; i < t; i++) {
  n = parseInt(readline());
  var gregor = readline();
  var me = readline();
  print(solve(n, gregor, me));
}

function solve(n, gregor, me) {
  var taken = new Array(n).fill(false);
  var score = 0;

  for (var i = 0; i < n; i++) {
    if (gregor[i] === "1") taken[i] = true;
  }

  for (var _i = 0; _i < n; _i++) {
    if (me[_i] !== "1") continue;

    if (_i - 1 >= 0 && taken[_i - 1]) {
      score++;
      taken[_i - 1] = true;
    } else if (!taken[_i]) {
      taken[_i] = true;
      score++;
    } else if (_i + 1 < n && taken[_i + 1]) {
      score++;
      taken[_i + 1] = true;
    }
  }

  return score;
}

var t = parseInt(readline());

for (var i = 0; i < t; i++) {
  n = parseInt(readline());
  gregor = readline();
  me = readline();
  print(solve(n, gregor, me));
}

var t = readline()

while (t--) {
    solve();
}

function solve() {
    var n = readline();
    var st = readline();
    var st2 = readline();

    var cont = 0;

    for (var i = 0; i < n; i++){
        if (st2[i] === '1') {
            if (st[i] === '0') {
                cont++;
                st[i] = '3';
                continue;
            }
            if (i > 0 && st[i - 1] === '1') {
                st[i - 1] = '3';
                cont++;
                continue;
            }
            if (i < n - 1 && st[i + 1] === '1') {
                st[i + 1] = 3;
                cont++;
            }
        }
    }

    write(cont + '\n');
}


Phoenix has collected $$$n$$$ pieces of gold, and he wants to weigh them together so he can feel rich. The $$$i$$$-th piece of gold has weight $$$w_i$$$. All weights are distinct. He will put his $$$n$$$ pieces of gold on a weight scale, one piece at a time. The scale has an unusual defect: if the total weight on it is exactly $$$x$$$, it will explode. Can he put all $$$n$$$ gold pieces onto the scale in some order, without the scale exploding during the process? If so, help him find some possible order. Formally, rearrange the array $$$w$$$ so that for each $$$i$$$ $$$(1 \le i \le n)$$$, $$$\sum\limits_{j = 1}^{i}w_j \ne x$$$.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 100$$$; $$$1 \le x \le 10^4$$$) — the number of gold pieces that Phoenix has and the weight to avoid, respectively.  The second line of each test case contains $$$n$$$ space-separated integers $$$(1 \le w_i \le 100)$$$ — the weights of the gold pieces. It is guaranteed that the weights are pairwise distinct.

For each test case, if Phoenix cannot place all $$$n$$$ pieces without the scale exploding, print NO. Otherwise, print YES followed by the rearranged array $$$w$$$. If there are multiple solutions, print any.

NoteIn the first test case, Phoenix puts the gold piece with weight $$$3$$$ on the scale first, then the piece with weight $$$2$$$, and finally the piece with weight $$$1$$$. The total weight on the scale is $$$3$$$, then $$$5$$$, then $$$6$$$. The scale does not explode because the total weight on the scale is never $$$2$$$.In the second test case, the total weight on the scale is $$$8$$$, $$$9$$$, $$$11$$$, $$$14$$$, then $$$18$$$. It is never $$$3$$$.In the third test case, Phoenix must put the gold piece with weight $$$5$$$ on the scale, and the scale will always explode.

//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{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
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 t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var X = nextInt();
		var list = nextIntArray(N);
		list.sort(function(a,b){
			return b - a;
		});
		var sum = 0;
		for(var j = 0; j < N; j++){
			sum += list[j];
		}
		if(sum == X){
			myout("NO");
		}else{
			myout("YES");
			while(true){
				var sum = 0;
				var isOK = true;
				for(var j = 0; j < N; j++){
					sum += list[j];
					if(sum == X){
						isOK = false;
						break;
					}
				}
				if(isOK){
					break;
				}else{
					list.push(list.shift());
				}
			}
			myout(myconv(list, 8));
		}
	}
}

'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++];
}
/**
3
3 2
3 2 1
5 3
1 2 3 4 8
1 5
5

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function lcm(a, b) {
    return (a / gcd(a, b) * b);
}

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve();
    }

}

function solve() {
    let [n, t] = readline().split(" ").map(Number);
    let data = readline().split(" ").map(Number);

    //let output = [];
    let total = 0;

    for(let i=0;i<data.length;i++) {
        total = total + data[i];
        if(total === t && i+1 !== data.length) {
            [data[i], data[i+1]] = [data[i+1], data[i]];
        }
    }

    if(total === t) {
        console.log('No');
    } else {
        console.log('Yes');
        console.log(data.join(" "));
    }

}

//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{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
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 t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var X = nextInt();
		var list = nextIntArray(N);
		list.sort(function(a,b){
			return b - a;
		});
		var sum = 0;
		for(var j = 0; j < N; j++){
			sum += list[j];
		}
		if(sum == X){
			myout("NO");
		}else{
			myout("YES");
			if(list[0] == X){
				list.push(list.shift());
			}
			myout(myconv(list, 8));
		}
	}
}

//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{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
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 t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var X = nextInt();
		var list = nextIntArray(N);
		list.sort(function(a,b){
			return b - a;
		});
		var sum = 0;
		for(var j = 0; j < N; j++){
			sum += list[j];
		}
		if(sum == X){
			myout("NO");
		}else{
			myout("YES");
			myout(myconv(list, 8));
		}
	}
}


Martian scientists explore Ganymede, one of Jupiter's numerous moons. Recently, they have found ruins of an ancient civilization. The scientists brought to Mars some tablets with writings in a language unknown to science.They found out that the inhabitants of Ganymede used an alphabet consisting of two letters, and each word was exactly $$$\ell$$$ letters long. So, the scientists decided to write each word of this language as an integer from $$$0$$$ to $$$2^{\ell} - 1$$$ inclusively. The first letter of the alphabet corresponds to zero bit in this integer, and the second letter corresponds to one bit.The same word may have various forms in this language. Then, you need to restore the initial form. The process of doing it is described below.Denote the distance between two words as the amount of positions, in which these words differ. For example, the distance between $$$1001_2$$$ and $$$1100_2$$$ (in binary) is equal to two, as these words have different letters in the second and the fourth positions, counting from left to right. Further, denote the distance between words $$$x$$$ and $$$y$$$ as $$$d(x, y)$$$.Let the word have $$$n$$$ forms, the $$$i$$$-th of which is described with an integer $$$x_i$$$. All the $$$x_i$$$ are not necessarily different, as two various forms of the word can be written the same. Consider some word $$$y$$$. Then, closeness of the word $$$y$$$ is equal to the sum of distances to each of the word forms, i. e. the sum $$$d(x_i, y)$$$ over all $$$1 \le i \le n$$$.The initial form is the word $$$y$$$ with minimal possible nearness.You need to help the scientists and write the program which finds the initial form of the word given all its known forms. Note that the initial form is not necessarily equal to any of the $$$n$$$ given forms.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The following are descriptions of the test cases. The first line contains two integers $$$n$$$ and $$$\ell$$$ ($$$1 \le n \le 100$$$, $$$1 \le \ell \le 30$$$) — the amount of word forms, and the number of letters in one word. The second line contains $$$n$$$ integers $$$x_i$$$ ($$$0 \le x_i \le 2^\ell - 1$$$) — word forms. The integers are not necessarily different.

For each test, print a single integer, the initial form of the word, i. e. such $$$y$$$ ($$$0 \le y \le 2^\ell - 1$$$) that the sum $$$d(x_i, y)$$$ over all $$$1 \le i \le n$$$ is minimal possible. Note that $$$y$$$ can differ from all the integers $$$x_i$$$. If there are multiple ways to restore the initial form, print any.

NoteIn the first test case, the words can be written as $$$x_1 = 10010_2$$$, $$$x_2 = 01001_2$$$ and $$$x_3 = 10101_2$$$ in binary. Let $$$y = 10001_2$$$. Then, $$$d(x_1, y) = 2$$$ (the difference is in the fourth and the fifth positions), $$$d(x_2, y) = 2$$$ (the difference is in the first and the second positions), $$$d(x_3, y) = 1$$$ (the difference is in the third position). So, the closeness is $$$2 + 2 + 1 = 5$$$. It can be shown that you cannot achieve smaller closeness.In the second test case, all the forms are equal to $$$18$$$ ($$$10010_2$$$ in binary), so the initial form is also $$$18$$$. It's easy to see that closeness is equal to zero in this case.

let dataitr;
let stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", (input) => {
  stdin_input += input;
});
process.stdin.on("end", () => {
  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));
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const t = rn();

  for (let ti = 0; ti < t; ti++) {
    const [n, l] = rna();
    const x = rna();

    const hash = Array.from({ length: l }, () => 0);

    for (const xi of x) {
      const s = xi.toString(2).padStart(l, "0");
      for (let i = 0; i < s.length; i++) {
        if (s[i] === "1") {
          hash[i]++;
        } else {
          hash[i]--;
        }
      }
    }

    let local = "";
    for (let i = 0; i < hash.length; i++) {
      if (hash[i] > 0) {
        local += "1";
      } else {
        local += "0";
      }
    }

    console.log(parseInt(local, 2));
  }
}

let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader ();

function _main() {

	_inputLines = _inputData.trim().split('\n').map((string) => {
		return string.trim();
	});;

	let t = inputReader.readNumber();

	function solve() {
	  let [n,l] = inputReader.readNumberArray();
	  let v = inputReader.readNumberArray();
	  let bits = new Array(l).fill(0);
	  v.forEach(x => {
	    for(let k = 0; k < l; k++){
	      bits[k]+= x & (1 << k) ? 1 : 0;
	    }
	  });
	  let ans = 0;
	  for(let k = 0; k < l; k++){
	    if(bits[k] > (n - bits[k])) ans += (1 << k);
	  }
	  console.log(ans);
	}

	while (t--) {
	  solve();
	}
}

var _inputData = '';
function cacheInput(data) {
	_inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', cacheInput).on('end', _main);

function _inputReader () {
	function readNumber(){
		return Number(_inputLines[_lineNumber++]);
	}

	function readNumberArray(){
		return _inputLines[_lineNumber++].split(' ').map(val => Number(val));
	}

	return {
		readNumber,
		readNumberArray,
	}
}

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));

function main () {
	let T = rn();
	while (T--) {
		const [n, l] = rna();
		const x = rna();

		let ans = 0;
		for (let i = 0; i < l; i++) {
			let cnt = 0;
			for (let j = 0; j < n; j++) {
				cnt += (x[j] >> i) & 1;
			}
			if (cnt >= n - cnt)
				ans += 1 << i;
		}

		console.log(ans);
	}
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [n, k] = lines[l++].trim().split(' ').map(Number)
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, k, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, k, arr) {
    let ans = 0
    for (let i = 0; i <= 30; i++) {
        let now = 0
        arr.forEach(x => {
            if (x & (1 << i)) now++
        })
        if (now >= n / 2) {
            ans |= 1 << i
        }
    }
    return ans
}