description: 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.
  
  Input
  
  The first line of the input contains one integer t (1≤ t≤ 2⋅ 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≤ n≤ 2⋅{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⋅{10}^{5}.
  
  Output
  
  For each test case, print one integer: the maximum number of Gregor's pawns which can reach the 1-st row.
  
  Example
  
  Input
  
  
  4
  3
  000
  111
  4
  1111
  1111
  3
  010
  010
  5
  11001
  00000
  
  
  Output
  
  
  3
  4
  0
  0
  
  Note
  
  In 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"!
  
  <image>
  
  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.
solution: import java.io.DataInputStream;
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.util.AbstractMap;
  import java.util.Comparator;
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Map.Entry;
  import java.util.PriorityQueue;
  import java.util.*;
  import java.io.*;
  
  // Java Template Pramod Hosahalli...
  @SuppressWarnings("unused")
  public class Solution {
  
  	//static FastReader in = new FastReader();
  	static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  	static int mod = 1000000007;
  
  	private static void go() throws Exception{
  		int n = pi(in.readLine());
  		char[] fx = in.readLine().toCharArray();
  		char[] fy = in.readLine().toCharArray();
  		
  		int count = 0;
  		for(int i = 0; i < n; i++){
  			if(fy[i] == '0')
  				continue;
  			
  			if(fy[i] == '1')
  			{
  				//is there a chance to take previous pawn ?
  				if(i-1 >= 0 && fx[i-1] == '1'){count++;}
  				else if(fx[i] == '0')count++;
  				else if(i + 1 < n && fx[i+1] == '1'){ count++; fx[i+1]='A'; }
  			}
  		}
  		print(1,count+"");
  
      }
  
  	public static void main(String[] args) throws Exception {
  		//int t = in.ni();
          int t = pi(in.readLine());
  		for(int _i = 1; _i <= t; _i++){
  			go();
  		}
  		in.close();
  	}
  
  	static long mul(long a, long b) {
  		return ((a % mod) * (b % mod)) % mod;
  	}
  
  	static class FastReader {
  		final private int BUFFER_SIZE = 1 << 16;
  		private DataInputStream din;
  		private byte[] buffer;
  		private int bufferPointer, bytesRead;
  
  		public FastReader() {
  			din = new DataInputStream(System.in);
  			buffer = new byte[BUFFER_SIZE];
  			bufferPointer = bytesRead = 0;
  		}
  
  		public FastReader(String file_name) throws IOException {
  			din = new DataInputStream(new FileInputStream(file_name));
  			buffer = new byte[BUFFER_SIZE];
  			bufferPointer = bytesRead = 0;
  		}
  
  		public String readLine() throws IOException {
  			byte[] buf = new byte[64]; // line length
  			int cnt = 0, c;
  			while ((c = read()) != -1) {
  				if (c == '\n') {
  					if (cnt != 0) {
  						break;
  					} else {
  						continue;
  					}
  				}
  				buf[cnt++] = (byte) c;
  			}
  			return new String(buf, 0, cnt);
  		}
  
  		public int ni() throws IOException {
  			int ret = 0;
  			byte c = read();
  			while (c <= ' ') {
  				c = read();
  			}
  			boolean neg = (c == '-');
  			if (neg)
  				c = read();
  			do {
  				ret = ret * 10 + c - '0';
  			} while ((c = read()) >= '0' && c <= '9');
  
  			if (neg)
  				return -ret;
  			return ret;
  		}
  
  		public long nl() throws IOException {
  			long ret = 0;
  			byte c = read();
  			while (c <= ' ')
  				c = read();
  			boolean neg = (c == '-');
  			if (neg)
  				c = read();
  			do {
  				ret = ret * 10 + c - '0';
  			} while ((c = read()) >= '0' && c <= '9');
  			if (neg)
  				return -ret;
  			return ret;
  		}
  
  		public double nd() throws IOException {
  			double ret = 0, div = 1;
  			byte c = read();
  			while (c <= ' ')
  				c = read();
  			boolean neg = (c == '-');
  			if (neg)
  				c = read();
  
  			do {
  				ret = ret * 10 + c - '0';
  			} while ((c = read()) >= '0' && c <= '9');
  
  			if (c == '.') {
  				while ((c = read()) >= '0' && c <= '9') {
  					ret += (c - '0') / (div *= 10);
  				}
  			}
  
  			if (neg)
  				return -ret;
  			return ret;
  		}
  
  		private void fillBuffer() throws IOException {
  			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
  			if (bytesRead == -1)
  				buffer[0] = -1;
  		}
  
  		private byte read() throws IOException {
  			if (bufferPointer == bytesRead)
  				fillBuffer();
  			return buffer[bufferPointer++];
  		}
  
  		public void close() throws IOException {
  			if (din == null)
  				return;
  			din.close();
  		}
  	}
  
  	static String rl() throws Exception{
  		return in.readLine();
  	}
  
  	static int pi(String s) {
  		return Integer.parseInt(s);
  	}
  
  	static long pl(String s) {
  		return Long.parseLong(s);
  	}
  
  	static void print(int newline, String s) {
  		System.out.print(s);
  		if (newline != 0)
  			System.out.println();
  		// System.out.flush();
  	}
  
  	static void cprint(int x) {
  		print(0, "Case #" + x + ": ");
  	}
  }