// Subtasks:
// 1: AC
// 2: AC
// 3: AC
// 4: AC 26

// phase 1: 3 groups, internally linear
// phase 2: find 3-node cycle deterministically by growing a chain.
//          always at most 2n queries

#include <iostream>
#include <vector>
#include <cassert>

using namespace std;

bool ask(int u, int v) {
    assert(u != v);
    cout << "? " << u << " " << v << endl;
    char ans;
    cin >> ans;
    return ans == '>';
}

int main() {
    int n, t;
    cin >> n >> t;

    int gs1 = (n + 2) / 3, gs2 = (n + 1) / 3, gs3 = n / 3;
    auto get_group = [=](int x) {
      if (x <= gs1) return 1;
      if (x <= gs1+gs2) return 2;
      return 3;
    };

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            int ig = get_group(i);
            int jg = get_group(j);
            bool f;
            if (ig != jg) {
                // 1 -> 2, 2 -> 3, 3 -> 1
                f = (ig == 1 && jg == 2) || (ig == 2 && jg == 3) || (ig == 3 && jg == 1);
            } else {
                f = i < j;
            }
            if (f) cout << '1';
            else cout << '0';
        }
        cout << endl;
    }

    for (int ti = 0; ti < t; ++ti) {
        vector<int> chain;
        vector<vector<int>> tails(2);
        if (ask(1, 2)) chain = {1, 2};
        else chain = {2, 1};
        int rep3 = 0;
        for (int i = 3; i <= n; ++i) {
            if (ask(chain.back(), i)) {
                if (ask(chain.front(), i)) {
                    chain.push_back(i);
                    tails.emplace_back();
                } else {
                    rep3 = i;
                    break;
                }
            } else {
                tails.back().push_back(i);
            }
        }

        vector<int> gl[4];
        vector<int> g(n+1);
        auto set_group = [&](int x, int gi) {
            if (g[x]) {
                assert(g[x] == gi);
                return;
            }
            gl[gi].push_back(x);
            g[x] = gi;
        };

        int rep1 = chain.front(), rep2 = chain.back();

        if (rep3) {
            set_group(rep3, 3);
            for (int i = rep3+1; i <= n; ++i) {
                if (ask(rep1, i)) {
                    // in either 1 or 2
                    if (ask(rep3, i)) set_group(i, 1);
                    else set_group(i, 2);
                } else {
                    // in either 1 or 3
                    if (ask(rep2, i)) set_group(i, 3);
                    else set_group(i, 1);
                }
            }
        } else {
            // No 3-cycle found. Check tails from front until we find something in group 3.
            for (auto &tl : tails) {
                for (int x : tl) {
                    // x in either 1 or 3
                    if (ask(rep2, x)) {
                        set_group(x, 3);
                        rep3 = x;
                    } else set_group(x, 1);
                }
                tl.clear();
                if (rep3) break;
            }
        }

        // chain.pop_back();
        // chain.erase(chain.begin());

        while (chain.size() > 1 && (int)gl[2].size() < gs3) {
            int x = chain.back();
            set_group(x, 2);
            for (int y : tails.back()) {
                // y in either 1 or 2
                if (ask(rep3, y)) set_group(y, 1);
                else set_group(y, 2);
            }
            chain.pop_back();
            tails.pop_back();
        }

        if (chain.size() > 1 && (int)gl[2].size() < gs1) {
            int x = chain.back();
            // x in either 1 or 2
            if (ask(rep3, x)) set_group(x, 1);
            else {
                set_group(x, 2);
                // y either in 1 or 2, no more space in 2
                for (int y : tails.back()) set_group(y, 1);
                chain.pop_back();
                tails.pop_back();
            }
        }

        for (int x : chain) set_group(x, 1);

        for (const auto &tl : tails) {
            for (int x : tl) {
                // x either in 1 or 3
                if (ask(rep2, x)) set_group(x, 3);
                else set_group(x, 1);
            }
        }

        bool oversize[4];
        for (int gi : {1, 2, 3}) oversize[gi] = (int)gl[gi].size() > gs3;
        int cg = 1;
        vector<int> ans;
        for (int i = 1; i <= n; ++i) {
            int x = gl[cg].back();
            gl[cg].pop_back();
            ans.push_back(x);
            if (oversize[cg]) {
                int y = gl[cg].back();
                gl[cg].pop_back();
                if (!ask(x, y)) swap(ans.back(), y);
                ans.push_back(y);
                oversize[cg] = 0;
                i++;
            }
            cg = cg == 3 ? 1 : cg+1;
        }

        cout << "! ";
        for (int x : ans) cout << x << " ";
        cout << endl;
    }
}
