Need help with Google Codejam 2019 Qualification Round Interactive problem

I need help with interactive problem of Codejam Qualification Round 2019. Below is my implementation for the same. It is throwing a runtime error. Can anyone please point out where am I making a mistake?

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define vi vector<int>
#define pb push_back

string read(string s) { string x; cout << s << endl; cin >> x; return x;}

int n, b, f;
vector<string> in, out;

void read_strings() {
    int p = ceil(log2(n));

    rep (i, min(f, p)) {
        int bits = pow(2, i);
        string s(n, ' ');

        rep (j, n) {
            s[j] = ((j/bits)%2 == 0) ? '0' : '1';
        }

        in.pb(s);
        out.pb(read(s));
    }
}

string col (vector<string> v, int j) {
    string s = "";
    rep (i, v.size())
        s += v[i][j];

    return s;
}

void solve () {

    int t; cin >> t;
    while (t--) {

        cin >> n >> b >> f;
        in.clear();
        out.clear();
        read_strings();

        int i, j; i = j = 0;
        string s1, s2;

        vector<int> ans;
        while (i < n && j < n-b) {
            s1 = col(in, i);
            s2 = col(out, j);
            if (s1 == s2) j++;
            else ans.pb(i);
            i++;
        }

        stringstream ss;
        rep(i, b) {
            ss << ans[i];
            if (i != b-1) ss << " "; 
        }

        cout << ss.str() << endl;
        int verdict; cin >> verdict;
        assert(verdict == 1);
    }
}

int32_t main(){
    solve();
    return 0;
}