Consider the following process. You have a binary string (a string where each character is either 0 or 1) w of length n and an integer x. You build a new binary string s consisting of n characters. The i-th character of s is chosen as follows:

  * if the character w_{i-x} exists and is equal to 1, then s_i is 1 (formally, if i > x and w_{i-x} =  1, then s_i =  1); 
  * if the character w_{i+x} exists and is equal to 1, then s_i is 1 (formally, if i + x ≤ n and w_{i+x} =  1, then s_i =  1); 
  * if both of the aforementioned conditions are false, then s_i is 0. 



You are given the integer x and the resulting string s. Reconstruct the original string w.

Input

The first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases.

Each test case consists of two lines. The first line contains the resulting string s (2 ≤ |s| ≤ 10^5, each character of s is either 0 or 1). The second line contains one integer x (1 ≤ x ≤ |s| - 1).

The total length of all strings s in the input does not exceed 10^5.

Output

For each test case, print the answer on a separate line as follows:

  * if no string w can produce the string s at the end of the process, print -1; 
  * otherwise, print the binary string w consisting of |s| characters. If there are multiple answers, print any of them. 

Example

Input


3
101110
2
01
1
110
1


Output


111011
10
-1

import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Solution{

    static class Pair<A, B> {

        A parent;
        B rank;

        Pair(A parent, B rank) {
            this.rank = rank;
            this.parent = parent;
        }
    }
    static class Node {
        int index;
        int w;
        Node(int k,int l)
        {
            index=k;w=l;
        }
    }
    static class Gnode{
        int v;
        int no;
        Gnode(int g,int i)
        {
            v=g;
            no=i;
        }
    }
    static int m=1000000007;
    static int dp[][];
    public static void main(String[] args) throws IOException {
        FastReader s1 = new FastReader();
        StringBuilder sb = new StringBuilder();
        int t=s1.I();
        while(t--!=0)
        {
            char ar[] = s1.next().toCharArray();
            int n=ar.length;
            char res[] = new char[ar.length];
            Arrays.fill(res, '0');
            int x=s1.I();
            boolean ans=true;
            for(int i=0;i<n;i++)
            {
                if(ar[i]=='1')
                {
                    if((i-x)>=0)
                    {
                        if(res[i-x]=='1')
                        {}
                        else if(isValid(i-x, x, ar))
                        {
                            res[i-x]='1';
                        }
                        else if(i+x<n)
                        {
                            if(isValid(i+x, x, ar))
                            {
                                res[i+x]='1';
                            }
                            else
                            {
                                ans=false;
                                break;
                            }
                        }
                        else
                        {
                            ans=false;
                            break;
                        }
                    }
                    else
                    {
                        if(i+x<n && isValid(i+x, x, ar))
                        {
                            res[i+x]='1';
                        }
                        else
                        {
                            ans=false;
                            break;
                        }
                    }
                }
            }
            if(ans)
            {
                sb.append(new String(res)).append("\n");
            }
            else
                sb.append("-1\n");
        }
        System.out.println(sb);
    }
    static boolean isValid(int i,int x,char ar[])
    {
        if(i<0)
            return true;
        if(i>=ar.length)
            return true;
        if((i-x)>=0)
        {
            if(ar[i-x]=='0')
                return false;
        }
        if((i+x)<ar.length && ar[i+x]=='0')
            return false;
        return true;
    }
    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

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

    static float power(float x, int y) {
        float temp;
        if (y == 0) {
            return 1;
        }
        temp = power(x, y / 2);

        if (y % 2 == 0) {
            return temp * temp;
        } else {
            if (y > 0) {
                return x * temp * temp;
            } else {
                return (temp * temp) / x;
            }
        }
    }
    static long pow(long x, long y) {
        long res = 1;
        x = x % m;
        if (x < 0) {
            x += m;
        }
        while (y > 0) {
            if ((y & 1) == 1) {
                res = (res * x) % m;
                if (res < 0) {
                    res += m;
                }
            }
            y = y >> 1;
            x = (x * x) % m;
            if (x < 0) {
                x = x + m;
            }
        }
        res = res % m;
        if (res < 0) {
            res += m;
        }
        return res;
    }

    static void sieveOfEratosthenes(int n) {
        ArrayList<Integer> prime = new ArrayList<Integer>();
        boolean Prime[] = new boolean[n + 1];
        for (int i = 2; i < n; i++) {
            Prime[i] = true;
        }

        for (int p = 2; p * p <= n; p++) {
            if (Prime[p] == true) {
                prime.add(p);
                for (int i = p * p; i <= n; i += p) {
                    Prime[i] = false;
                }
            }
        }
    }
}
