// Arup Guha
// 10/8/2015
// Solution to 2001 UCF HS Contest Problem: Genetic Algorithms

import java.util.*;

public class genetic {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case.
		for (int loop=0; loop<numCases; loop++) {

			// Store as a character array, flip the bit and print result.
			int flip = stdin.nextInt()-1;
			char[] gene = stdin.next().toCharArray();
			gene[flip] = gene[flip] == '0' ? '1' : '0';
			System.out.println(new String(gene));
			System.out.println();
		}
	}
}