#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define z third
#define pb push_back
#define ins insert
#define len(x) (int) x.size()
#define all(a) a.begin(), a.end()

#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define tests() int QQQ; cin >> QQQ; for (; QQQ > 0; --QQQ)
#define press_f cout << ">>>===== F =====<<<" << endl << endl;
#define input(a) for (int i = 0; i < a.size(); ++i) cin >> a[i];
#define print(x, text) cout << text << " = " << x << endl;
#define printv(x, text) cout << text << " = "; for (auto e : x) cout << e << ' '; cout << endl;
#define printvp(x, text) cout << text << " =\n"; for (auto e : x) cout << e.first << ' ' << e.second << endl; cout << endl;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int inf = 1e9;
const ll inf_ll = 1e18;

template <typename T> int min_idx(T a) {
    int res = -1;
    for (int i = 0; i < len(a); ++i) {
        if (res == -1 || a[i] < a[res])
            res = i;
    }
    return res;
}

int main() {
    fast_io;

    int n, k;
    cin >> n >> k;

    vi a(n, -1);

    for (int i = 0; i < n; ++i) {
        vi q;
        for (int j = 0; j < n; ++j) {
            if (a[j] == -1) q.pb(j + 1);
            if (len(q) == k) break;
        }
        if (len(q) < k) continue;

        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;

        int idx, x;
        cin >> idx >> x;
        a[idx - 1] = x;
    }
    //printv(a, "a");

    if (n - k + 1 >= k) {
        vi q;
        for (int j = 0; j < n; ++j) {
            if (a[j] != -1) q.pb(j + 1);
            if (len(q) == k) break;
        }
        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;

        int idx, x;
        cin >> idx >> x;
        idx--;

        vi t(k);
        for (int i = 0; i < k; ++i) {
            t[i] = a[q[i] - 1];
        }
        sort(all(t));

        int ans = 0;
        for (int i = 0; i < k; ++i) {
            if (x == t[i]) {
                ans = i + 1;
                break;
            }
        }

        cout << "! " << ans << endl;
        return 0;
    }

    vi un;
    for (int i = 0; i < n; ++i) {
        if (a[i] == -1) un.pb(i);
    }
    vi kn;
    for (int i = 0; i < n; ++i) {
        if (a[i] != -1) kn.pb(i);
        if (len(kn) + len(un) == k + 1) break;
    }
    int mn = a[kn[0]];
    for (int i = 0; i < len(kn); ++i) {
        if (a[kn[i]] < mn) mn = a[kn[i]];
    }
    //print(mn, "min_kn");

    for (int i = 0; i < len(un); ++i) {
        vi q;
        for (int j = 0; j < len(un); ++j) {
            if (i == j) continue;
            q.pb(un[j] + 1);
        }
        for (auto e : kn) q.pb(e + 1);

        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;

        int idx, x;
        cin >> idx >> x;
        idx--;

        if (x != mn) {
            a[un[i]] = -2;
        }
    }
    int ans = 0;
    for (auto e : a) if (e == -2) ans++;
    //printv(a, "a");

    cout << "! " << ans + 1 << endl;
}

/*
8 5
3 7
6 21
7 17
8 18

6 21
3 7
3 7
6 21
*/


#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define z third
#define pb push_back
#define ins insert
#define len(x) (int) x.size()
#define all(a) a.begin(), a.end()

#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define tests() int QQQ; cin >> QQQ; for (; QQQ > 0; --QQQ)
#define press_f cout << ">>>===== F =====<<<" << endl << endl;
#define input(a) for (int i = 0; i < a.size(); ++i) cin >> a[i];
#define print(x, text) cout << text << " = " << x << endl;
#define printv(x, text) cout << text << " = "; for (auto e : x) cout << e << ' '; cout << endl;
#define printvp(x, text) cout << text << " =\n"; for (auto e : x) cout << e.first << ' ' << e.second << endl; cout << endl;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int inf = 1e9;
const ll inf_ll = 1e18;

template <typename T> int min_idx(T a) {
    int res = -1;
    for (int i = 0; i < len(a); ++i) {
        if (res == -1 || a[i] < a[res])
            res = i;
    }
    return res;
}

int main() {
    fast_io;

    int n, k;
    cin >> n >> k;

    if (k == 1) {
        cout << "! 1" << endl;
        return 0;
    }

    int cnt = 0;

    vi a(n, -1);

    for (int i = 0; i < n; ++i) {
        vi q;
        for (int j = 0; j < n; ++j) {
            if (a[j] == -1) q.pb(j + 1);
            if (len(q) == k) break;
        }
        if (len(q) < k) continue;

        assert(len(q) == k);
        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;
        cnt++; assert(cnt <= n);

        int idx, x;
        cin >> idx >> x;
        a[idx - 1] = x;
    }
    //printv(a, "a");

    if (n - k + 1 >= k) {
        vi q;
        for (int j = 0; j < n; ++j) {
            if (a[j] != -1) q.pb(j + 1);
            if (len(q) == k) break;
        }
        assert(len(q) == k);
        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;
        cnt++; assert(cnt <= n);

        int idx, x;
        cin >> idx >> x;
        idx--;

        vi t(k);
        for (int i = 0; i < k; ++i) {
            t[i] = a[q[i] - 1];
        }
        sort(all(t));

        int ans = 0;
        for (int i = 0; i < k; ++i) {
            if (x == t[i]) {
                ans = i + 1;
                break;
            }
        }

        cout << "! " << ans << endl;
        return 0;
    }

    vi un;
    for (int i = 0; i < n; ++i) {
        if (a[i] == -1) un.pb(i);
    }
    assert(len(un) == k - 1);

    vi kn;
    int mn = 1e9 + 1;
    for (int i = 0; i < n; ++i) {
        if (a[i] != -1) kn.pb(i);
        if (a[i] != -1 && a[i] < mn) mn = a[i];
        if (len(kn) + len(un) == k + 1) break;
    }
    assert(len(kn) == 2);
    assert(mn != (int) 1e9 + 1);

    int ans = 0;
    for (int i = 0; i < len(un); ++i) {
        vi q;
        for (int j = 0; j < len(un); ++j) {
            if (i == j) continue;
            q.pb(un[j] + 1);
        }
        for (auto e : kn) q.pb(e + 1);

        assert(len(q) == k);
        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;
        cnt++; assert(cnt <= n);

        int idx, x;
        cin >> idx >> x;
        idx--;

        if (x != mn) {
            ans++;
        }
    }

    cout << "! " << ans + 1 << endl;
}

/*
8 5
3 7
6 21
7 17
8 18

6 21
3 7
3 7
6 21
*/


#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define z third
#define pb push_back
#define ins insert
#define len(x) (int) x.size()
#define all(a) a.begin(), a.end()

#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define tests() int QQQ; cin >> QQQ; for (; QQQ > 0; --QQQ)
#define press_f cout << ">>>===== F =====<<<" << endl << endl;
#define input(a) for (int i = 0; i < a.size(); ++i) cin >> a[i];
#define print(x, text) cout << text << " = " << x << endl;
#define printv(x, text) cout << text << " = "; for (auto e : x) cout << e << ' '; cout << endl;
#define printvp(x, text) cout << text << " =\n"; for (auto e : x) cout << e.first << ' ' << e.second << endl; cout << endl;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int inf = 1e9;
const ll inf_ll = 1e18;

template <typename T> int min_idx(T a) {
    int res = -1;
    for (int i = 0; i < len(a); ++i) {
        if (res == -1 || a[i] < a[res])
            res = i;
    }
    return res;
}

int main() {
    fast_io;

    int n, k;
    cin >> n >> k;

    vi a(n, -1);

    for (int i = 0; i < n; ++i) {
        vi q;
        for (int j = 0; j < n; ++j) {
            if (a[j] == -1) q.pb(j + 1);
            if (len(q) == k) break;
        }
        if (len(q) < k) continue;

        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;

        int idx, x;
        cin >> idx >> x;
        a[idx - 1] = x;
    }
    //printv(a, "a");

    if (n - k + 1 >= k) {
        vi q;
        for (int j = 0; j < n; ++j) {
            if (a[j] != -1) q.pb(j + 1);
            if (len(q) == k) break;
        }
        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;

        int idx, x;
        cin >> idx >> x;
        idx--;

        vi t(k);
        for (int i = 0; i < k; ++i) {
            t[i] = a[q[i] - 1];
        }
        sort(all(t));

        int ans = 0;
        for (int i = 0; i < k; ++i) {
            if (x == t[i]) {
                ans = i + 1;
                break;
            }
        }

        cout << "! " << ans << endl;
        return 0;
    }

    vi un;
    for (int i = 0; i < n; ++i) {
        if (a[i] == -1) un.pb(i);
    }
    vi kn;
    for (int i = 0; i < n; ++i) {
        if (a[i] != -1) kn.pb(i);
        if (len(a) + len(un) == k) break;
    }
    int mn = kn[min_idx(kn)];

    int ans = 0;
    for (int i = 0; i < len(un); ++i) {
        vi q;
        for (int j = 0; j < len(un); ++j) {
            if (i == j) continue;
            q.pb(un[j] + 1);
        }
        for (auto e : kn) q.pb(e + 1);

        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;

        int idx, x;
        cin >> idx >> x;
        idx--;

        if (x != mn) {
            ans++;
        }
    }

    cout << "! " << ans + 1 << endl;
}


#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define z third
#define pb push_back
#define ins insert
#define len(x) (int) x.size()
#define all(a) a.begin(), a.end()

#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define tests() int QQQ; cin >> QQQ; for (; QQQ > 0; --QQQ)
#define press_f cout << ">>>===== F =====<<<" << endl << endl;
#define input(a) for (int i = 0; i < a.size(); ++i) cin >> a[i];
#define print(x, text) cout << text << " = " << x << endl;
#define printv(x, text) cout << text << " = "; for (auto e : x) cout << e << ' '; cout << endl;
#define printvp(x, text) cout << text << " =\n"; for (auto e : x) cout << e.first << ' ' << e.second << endl; cout << endl;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int inf = 1e9;
const ll inf_ll = 1e18;

template <typename T> int min_idx(T a) {
    int res = -1;
    for (int i = 0; i < len(a); ++i) {
        if (res == -1 || a[i] < a[res])
            res = i;
    }
    return res;
}

int main() {
    fast_io;

    int n, k;
    cin >> n >> k;

    vi a(n, -1);

    for (int i = 0; i < n; ++i) {
        vi q;
        for (int j = 0; j < n; ++j) {
            if (a[j] == -1) q.pb(j + 1);
            if (len(q) == k) break;
        }
        if (len(q) < k) continue;

        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;

        int idx, x;
        cin >> idx >> x;
        a[idx - 1] = x;
    }
    //printv(a, "a");

    if (n - k + 1 >= k) {
        vi q;
        for (int j = 0; j < n; ++j) {
            if (a[j] != -1) q.pb(j + 1);
            if (len(q) == k) break;
        }
        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;

        int idx, x;
        cin >> idx >> x;
        idx--;

        vi t(k);
        for (int i = 0; i < k; ++i) {
            t[i] = a[q[i] - 1];
        }
        sort(all(t));

        int ans = 0;
        for (int i = 0; i < k; ++i) {
            if (x == t[i]) {
                ans = i + 1;
                break;
            }
        }

        assert(0);
        cout << "! " << ans << endl;
        return 0;
    }

    vi un;
    for (int i = 0; i < n; ++i) {
        if (a[i] == -1) un.pb(i);
    }
    vi kn;
    for (int i = 0; i < n; ++i) {
        if (a[i] != -1) kn.pb(i);
        if (len(kn) + len(un) == k + 1) break;
    }
    int mn = a[kn[0]];
    for (int i = 0; i < len(kn); ++i) {
        if (a[kn[i]] < mn) mn = a[kn[i]];
    }
    //print(mn, "min_kn");

    int ans = 0;
    for (int i = 0; i < len(un); ++i) {
        vi q;
        for (int j = 0; j < len(un); ++j) {
            if (i == j) continue;
            q.pb(un[j] + 1);
        }
        for (auto e : kn) q.pb(e + 1);

        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;

        int idx, x;
        cin >> idx >> x;
        idx--;

        if (x != mn) {
            ans++;
        }
    }

    cout << "! " << ans + 1 << endl;
}

/*
8 5
3 7
6 21
7 17
8 18

6 21
3 7
3 7
6 21
*/


#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define z third
#define pb push_back
#define ins insert
#define len(x) (int) x.size()
#define all(a) a.begin(), a.end()

#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define tests() int QQQ; cin >> QQQ; for (; QQQ > 0; --QQQ)
#define press_f cout << ">>>===== F =====<<<" << endl << endl;
#define input(a) for (int i = 0; i < a.size(); ++i) cin >> a[i];
#define print(x, text) cout << text << " = " << x << endl;
#define printv(x, text) cout << text << " = "; for (auto e : x) cout << e << ' '; cout << endl;
#define printvp(x, text) cout << text << " =\n"; for (auto e : x) cout << e.first << ' ' << e.second << endl; cout << endl;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int inf = 1e9;
const ll inf_ll = 1e18;

template <typename T> int min_idx(T a) {
    int res = -1;
    for (int i = 0; i < len(a); ++i) {
        if (res == -1 || a[i] < a[res])
            res = i;
    }
    return res;
}

int main() {
    fast_io;

    int n, k;
    cin >> n >> k;

    if (k == 1) {
        cout << 1 << endl;
        return 0;
    }

    vi a(n, -1);

    for (int i = 0; i < n; ++i) {
        vi q;
        for (int j = 0; j < n; ++j) {
            if (a[j] == -1) q.pb(j + 1);
            if (len(q) == k) break;
        }
        if (len(q) < k) continue;

        assert(len(q) == k);
        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;

        int idx, x;
        cin >> idx >> x;
        a[idx - 1] = x;
    }
    //printv(a, "a");

    if (n - k + 1 >= k) {
        vi q;
        for (int j = 0; j < n; ++j) {
            if (a[j] != -1) q.pb(j + 1);
            if (len(q) == k) break;
        }
        assert(len(q) == k);
        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;

        int idx, x;
        cin >> idx >> x;
        idx--;

        vi t(k);
        for (int i = 0; i < k; ++i) {
            t[i] = a[q[i] - 1];
        }
        sort(all(t));

        int ans = 0;
        for (int i = 0; i < k; ++i) {
            if (x == t[i]) {
                ans = i + 1;
                break;
            }
        }

        cout << "! " << ans << endl;
        return 0;
    }

    vi un;
    for (int i = 0; i < n; ++i) {
        if (a[i] == -1) un.pb(i);
    }
    assert(len(un) == k - 1);

    vi kn;
    int mn = 1e9 + 1;
    for (int i = 0; i < n; ++i) {
        if (a[i] != -1) kn.pb(i);
        if (a[i] != -1 && a[i] < mn) mn = a[i];
        if (len(kn) + len(un) == k + 1) break;
    }
    assert(len(kn) == 2);
    assert(mn != (int) 1e9 + 1);

    int ans = 0;
    for (int i = 0; i < len(un); ++i) {
        vi q;
        for (int j = 0; j < len(un); ++j) {
            if (i == j) continue;
            q.pb(un[j] + 1);
        }
        for (auto e : kn) q.pb(e + 1);

        assert(len(q) == k);
        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;

        int idx, x;
        cin >> idx >> x;
        idx--;

        if (x != mn) {
            ans++;
        }
    }

    cout << "! " << ans + 1 << endl;
}

/*
8 5
3 7
6 21
7 17
8 18

6 21
3 7
3 7
6 21
*/


#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define z third
#define pb push_back
#define ins insert
#define len(x) (int) x.size()
#define all(a) a.begin(), a.end()

#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define tests() int QQQ; cin >> QQQ; for (; QQQ > 0; --QQQ)
#define press_f cout << ">>>===== F =====<<<" << endl << endl;
#define input(a) for (int i = 0; i < a.size(); ++i) cin >> a[i];
#define print(x, text) cout << text << " = " << x << endl;
#define printv(x, text) cout << text << " = "; for (auto e : x) cout << e << ' '; cout << endl;
#define printvp(x, text) cout << text << " =\n"; for (auto e : x) cout << e.first << ' ' << e.second << endl; cout << endl;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int inf = 1e9;
const ll inf_ll = 1e18;

template <typename T> int min_idx(T a) {
    int res = -1;
    for (int i = 0; i < len(a); ++i) {
        if (res == -1 || a[i] < a[res])
            res = i;
    }
    return res;
}

int main() {
    fast_io;

    int n, k;
    cin >> n >> k;

    vi a(n, -1);

    for (int i = 0; i < n; ++i) {
        vi q;
        for (int j = 0; j < n; ++j) {
            if (a[j] == -1) q.pb(j + 1);
            if (len(q) == k) break;
        }
        if (len(q) < k) continue;

        assert(len(q) == k);
        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;

        int idx, x;
        cin >> idx >> x;
        a[idx - 1] = x;
    }
    //printv(a, "a");

    if (n - k + 1 >= k) {
        vi q;
        for (int j = 0; j < n; ++j) {
            if (a[j] != -1) q.pb(j + 1);
            if (len(q) == k) break;
        }
        assert(len(q) == k);
        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;

        int idx, x;
        cin >> idx >> x;
        idx--;

        vi t(k);
        for (int i = 0; i < k; ++i) {
            t[i] = a[q[i] - 1];
        }
        sort(all(t));

        int ans = 0;
        for (int i = 0; i < k; ++i) {
            if (x == t[i]) {
                ans = i + 1;
                break;
            }
        }

        cout << "! " << ans << endl;
        return 0;
    }

    vi un;
    for (int i = 0; i < n; ++i) {
        if (a[i] == -1) un.pb(i);
    }
    assert(len(un) == k - 1);

    vi kn;
    int mn = 1e9 + 1;
    for (int i = 0; i < n; ++i) {
        if (a[i] != -1) kn.pb(i);
        if (a[i] != -1 && a[i] < mn) mn = a[i];
        if (len(kn) + len(un) == k + 1) break;
    }
    assert(len(kn) == 2);
    assert(mn != (int) 1e9 + 1);

    int ans = 0;
    for (int i = 0; i < len(un); ++i) {
        vi q;
        for (int j = 0; j < len(un); ++j) {
            if (i == j) continue;
            q.pb(un[j] + 1);
        }
        for (auto e : kn) q.pb(e + 1);

        assert(len(q) == k);
        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;

        int idx, x;
        cin >> idx >> x;
        idx--;

        if (x != mn) {
            ans++;
        }
    }

    cout << "! " << ans + 1 << endl;
}

/*
8 5
3 7
6 21
7 17
8 18

6 21
3 7
3 7
6 21
*/


#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define z third
#define pb push_back
#define ins insert
#define len(x) (int) x.size()
#define all(a) a.begin(), a.end()

#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define tests() int QQQ; cin >> QQQ; for (; QQQ > 0; --QQQ)
#define press_f cout << ">>>===== F =====<<<" << endl << endl;
#define input(a) for (int i = 0; i < a.size(); ++i) cin >> a[i];
#define print(x, text) cout << text << " = " << x << endl;
#define printv(x, text) cout << text << " = "; for (auto e : x) cout << e << ' '; cout << endl;
#define printvp(x, text) cout << text << " =\n"; for (auto e : x) cout << e.first << ' ' << e.second << endl; cout << endl;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int inf = 1e9;
const ll inf_ll = 1e18;

template <typename T> int min_idx(T a) {
    int res = -1;
    for (int i = 0; i < len(a); ++i) {
        if (res == -1 || a[i] < a[res])
            res = i;
    }
    return res;
}

int main() {
    fast_io;

    int n, k;
    cin >> n >> k;

    if (k == 1) {
        cout << 1 << endl;
        return 0;
    }

    int cnt = 0;

    vi a(n, -1);

    for (int i = 0; i < n; ++i) {
        vi q;
        for (int j = 0; j < n; ++j) {
            if (a[j] == -1) q.pb(j + 1);
            if (len(q) == k) break;
        }
        if (len(q) < k) continue;

        assert(len(q) == k);
        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;
        cnt++; assert(cnt <= n);

        int idx, x;
        cin >> idx >> x;
        a[idx - 1] = x;
    }
    //printv(a, "a");

    if (n - k + 1 >= k) {
        vi q;
        for (int j = 0; j < n; ++j) {
            if (a[j] != -1) q.pb(j + 1);
            if (len(q) == k) break;
        }
        assert(len(q) == k);
        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;
        cnt++; assert(cnt <= n);

        int idx, x;
        cin >> idx >> x;
        idx--;

        vi t(k);
        for (int i = 0; i < k; ++i) {
            t[i] = a[q[i] - 1];
        }
        sort(all(t));

        int ans = 0;
        for (int i = 0; i < k; ++i) {
            if (x == t[i]) {
                ans = i + 1;
                break;
            }
        }

        cout << "! " << ans << endl;
        return 0;
    }

    vi un;
    for (int i = 0; i < n; ++i) {
        if (a[i] == -1) un.pb(i);
    }
    assert(len(un) == k - 1);

    vi kn;
    int mn = 1e9 + 1;
    for (int i = 0; i < n; ++i) {
        if (a[i] != -1) kn.pb(i);
        if (a[i] != -1 && a[i] < mn) mn = a[i];
        if (len(kn) + len(un) == k + 1) break;
    }
    assert(len(kn) == 2);
    assert(mn != (int) 1e9 + 1);

    int ans = 0;
    for (int i = 0; i < len(un); ++i) {
        vi q;
        for (int j = 0; j < len(un); ++j) {
            if (i == j) continue;
            q.pb(un[j] + 1);
        }
        for (auto e : kn) q.pb(e + 1);

        assert(len(q) == k);
        cout << "? "; for (auto e : q) cout << e << ' '; cout << endl;
        cnt++; assert(cnt <= n);

        int idx, x;
        cin >> idx >> x;
        idx--;

        if (x != mn) {
            ans++;
        }
    }

    cout << "! " << ans + 1 << endl;
}

/*
8 5
3 7
6 21
7 17
8 18

6 21
3 7
3 7
6 21
*/


#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N,K; cin >> N >> K;
	set<int> vivos;
	vi A(N+1);
	forn(i,1,N+1)vivos.insert(i);
	vi chidos;
	while(vivos.size() >= K){
		if(chidos.size() == K)break;
		int cnt = 0;
		cout << '?';
		for(auto &x : vivos){
			if(cnt == K)break;
			cout << ' ' << x;
			cnt++;
		}
		cout << endl;
		int pos,apos; cin >> pos >> apos;
		vivos.erase(pos);
		A[pos] = apos;
		chidos.pb(pos);
	}
	if(chidos.size() >= K){
		vi ord;
		cout << '?';
		forn(i,0,K){
			ord.pb(A[chidos[i]]);
			cout << ' ' << chidos[i];
		}
		cout << endl;
		sort(all(ord));
		int pos,apos; cin >> pos >> apos;
		forn(i,0,K){
			if(ord[i] == apos){
				cout << "! " << i+1 << endl;
				return 0;
			}
		}
	}else{
		vi ord,otros;
		forn(i,0,chidos.size()){
			ord.pb(A[chidos[i]]);
		}
		sort(all(ord));
		for(auto &x : vivos)otros.pb(x);
		set<int> diffs;
		int res = 0;
		forn(i,0,otros.size()){
			cout << '?';
			cout << ' ' << otros[i];
			forn(j,0,chidos.size())cout << ' ' << chidos[j];
			cout << endl;
			int pos,apos; cin >> pos >> apos;
			forn(j,0,ord.size()){
				if(ord[j] == apos){
					res = max(j+1,res);
					diffs.insert(apos);
				}
			}
		}
		if(diffs.size() == 1)cout << "! " << res+1 << endl;
		else cout << "! " << res << endl;
		return 0;
	}
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N,K; cin >> N >> K;
	set<int> vivos;
	vi A(N+1);
	forn(i,1,N+1)vivos.insert(i);
	vi chidos;
	while(vivos.size() >= K){
		if(chidos.size() == K)break;
		int cnt = 0;
		cout << '?';
		for(auto &x : vivos){
			if(cnt == K)break;
			cout << ' ' << x;
			cnt++;
		}
		cout << endl;
		int pos,apos; cin >> pos >> apos;
		vivos.erase(pos);
		A[pos] = apos;
		chidos.pb(pos);
	}
	if(chidos.size() >= K){
		vi ord;
		cout << '?';
		forn(i,0,K){
			ord.pb(A[chidos[i]]);
			cout << ' ' << chidos[i];
		}
		cout << endl;
		sort(all(ord));
		int pos,apos; cin >> pos >> apos;
		forn(i,0,K){
			if(ord[i] == apos){
				cout << "! " << i+1 << endl;
				return 0;
			}
		}
	}else{
		vi ord;
		cout << '?';
		int cnt = K;
		forn(i,0,chidos.size()){
			ord.pb(A[chidos[i]]);
			cout << ' ' << chidos[i];
			cnt--;
		}
		vi otros;
		while(cnt--){
			auto it = vivos.begin();
			cout << ' ' << *it;
			otros.pb(*it);
			vivos.erase(it);
		}
		cout << endl;

		sort(all(ord));
		int pos,apos; cin >> pos >> apos;
		int res = -1,val = -1;
		forn(i,0,ord.size()){
			if(ord[i] == apos){
				res = i+1;
				val = apos;
				break;
			}
		}
		ord = vi();
		cout << '?';
		cnt = K;
		forn(i,0,chidos.size()){
			if(A[chidos[i]] == val)continue;
			ord.pb(A[chidos[i]]);
			cout << ' ' << chidos[i];
			cnt--;
		}
		forn(i,0,otros.size()){
			cout << ' ' << otros[i];
			cnt--;
		}
		while(cnt--){
			auto it = vivos.begin();
                        cout << ' ' << *it;
                        vivos.erase(it);
		}
		cout << endl;
		sort(all(ord));
		cin >> pos >> apos;
		forn(i,0,ord.size()){
			if(ord[i] == apos){
				if(apos <= val){
					cout << "! " << res+1 << endl;
					return 0;
				}else{
					cout << "! " << res << endl;
				}
			}
		}
	}
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int oo = 1<<30;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N,K; cin >> N >> K;
	set<int> vivos;
	vi A(N+1);
	forn(i,1,N+1)vivos.insert(i);
	vi chidos;
	while(vivos.size() >= K){
		if(chidos.size() == K)break;
		int cnt = 0;
		cout << '?';
		for(auto &x : vivos){
			if(cnt == K)break;
			cout << ' ' << x;
			cnt++;
		}
		cout << endl;
		int pos,apos; cin >> pos >> apos;
		vivos.erase(pos);
		A[pos] = apos;
		chidos.pb(pos);
	}
	if(chidos.size() >= K){
		vi ord;
		cout << '?';
		forn(i,0,K){
			ord.pb(A[chidos[i]]);
			cout << ' ' << chidos[i];
		}
		cout << endl;
		sort(all(ord));
		int pos,apos; cin >> pos >> apos;
		forn(i,0,K){
			if(ord[i] == apos){
				cout << "! " << i+1 << endl;
				return 0;
			}
		}
	}else{
		vi ord,otros;
		forn(i,0,chidos.size()){
			ord.pb(A[chidos[i]]);
		}
		sort(all(ord));
		for(auto &x : vivos)otros.pb(x);
		set<int> diffs;
		int resmax = 0;
		int resmin = oo;
		forn(i,0,otros.size()){
			cout << '?';
			cout << ' ' << otros[i];
			forn(j,0,chidos.size())cout << ' ' << chidos[j];
			cout << endl;
			int pos,apos; cin >> pos >> apos;
			forn(j,0,ord.size()){
				if(ord[j] == apos){
					resmax = max(resmax,j+2);
					resmin = min(resmin,j+2);
					diffs.insert(apos);
				}
			}
		}
		if(diffs.size() == 1)cout << "! " << resmax << endl;
		else cout << "! " << resmin << endl;
		return 0;
	}
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int oo = 1<<30;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N,K; cin >> N >> K;
	set<int> vivos;
	vi A(N+1);
	forn(i,1,N+1)vivos.insert(i);
	vi chidos;
	while(vivos.size() >= K){
		if(chidos.size() == K)break;
		int cnt = 0;
		cout << '?';
		for(auto &x : vivos){
			if(cnt == K)break;
			cout << ' ' << x;
			cnt++;
		}
		cout << endl;
		int pos,apos; cin >> pos >> apos;
		vivos.erase(pos);
		A[pos] = apos;
		chidos.pb(pos);
	}
	if(chidos.size() >= K){
		vi ord;
		cout << '?';
		forn(i,0,K){
			ord.pb(A[chidos[i]]);
			cout << ' ' << chidos[i];
		}
		cout << endl;
		sort(all(ord));
		int pos,apos; cin >> pos >> apos;
		forn(i,0,K){
			if(ord[i] == apos){
				cout << "! " << i+1 << endl;
				return 0;
			}
		}
	}else{
		vi ord,otros;
		forn(i,0,chidos.size()){
			ord.pb(A[chidos[i]]);
		}
		sort(all(ord));
		for(auto &x : vivos)otros.pb(x);
		set<int> diffs;
		int resmax = 0;
		int resmin = oo;
		forn(i,0,otros.size()){
			cout << '?';
			cout << ' ' << otros[i];
			forn(j,0,chidos.size())cout << ' ' << chidos[j];
			cout << endl;
			int pos,apos; cin >> pos >> apos;
			forn(j,0,ord.size()){
				if(ord[j] == apos){
					resmax = max(resmax,j+1);
					resmin = min(resmin,j+1);
					diffs.insert(apos);
				}
			}
		}
		if(diffs.size() == 1)cout << "! " << resmax << endl;
		else cout << "! " << resmin << endl;
		return 0;
	}
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N,K; cin >> N >> K;
	set<int> vivos;
	vi A(N+1);
	forn(i,1,N+1)vivos.insert(i);
	vi chidos;
	while(vivos.size() >= K){
		if(chidos.size() == K)break;
		int cnt = 0;
		cout << '?';
		for(auto &x : vivos){
			if(cnt == K)break;
			cout << ' ' << x;
			cnt++;
		}
		cout << endl;
		int pos,apos; cin >> pos >> apos;
		vivos.erase(pos);
		A[pos] = apos;
		chidos.pb(pos);
	}
	if(chidos.size() >= K){
		vi ord;
		cout << '?';
		forn(i,0,K){
			ord.pb(A[chidos[i]]);
			cout << ' ' << chidos[i];
		}
		cout << endl;
		sort(all(ord));
		int pos,apos; cin >> pos >> apos;
		forn(i,0,K){
			if(ord[i] == apos){
				cout << "! " << i+1 << endl;
				return 0;
			}
		}
	}else{
		vi ord;
		cout << '?';
		int cnt = K;
		forn(i,0,chidos.size()){
			ord.pb(A[chidos[i]]);
			cout << ' ' << chidos[i];
			cnt--;
		}
		vi otros;
		while(cnt--){
			auto it = vivos.begin();
			cout << ' ' << *it;
			otros.pb(*it);
			vivos.erase(it);
		}
		cout << endl;

		sort(all(ord));
		int pos,apos; cin >> pos >> apos;
		int res = -1,val = -1;
		forn(i,0,ord.size()){
			if(ord[i] == apos){
				res = i+1;
				val = apos;
				break;
			}
		}
		ord = vi();
		cout << '?';
		cnt = K;
		forn(i,0,chidos.size()){
			if(A[chidos[i]] == val)continue;
			ord.pb(A[chidos[i]]);
			cout << ' ' << chidos[i];
			cnt--;
		}
		forn(i,0,otros.size()){
			cout << ' ' << otros[i];
			cnt--;
		}
		while(cnt--){
			auto it = vivos.begin();
                        cout << ' ' << *it;
                        vivos.erase(it);
		}
		cout << endl;
		sort(all(ord));
		cin >> pos >> apos;
		forn(i,0,ord.size()){
			if(ord[i] == apos){
				if(apos <= val){
					cout << "! " << res+1 << endl;
					return 0;
				}else{
					cout << "! " << res << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<math.h>
using namespace std;
main(){
       int a, b, n, k, pas=0;
       scanf ("%d%d", &n, &b);
      a=min(n, b);

      printf ("%d\n",  a+1);
      printf ("0 %d\n", a);
      for (pas=1; pas<=a; pas++){
          printf ("%d %d\n",  pas, pas);
          }

      }


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<math.h>
using namespace std;
main(){
       int a, b, n, k, pas=0;
       scanf ("%d%d", &n, &b);
      a=min(n, b);

      printf ("%d\n",  a+1);
      for (pas=0; pas<=a; pas++){
          printf ("%d %d\n",  pas, a-pas);
          }

      }


#include<iostream>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;

int a[100],b[100],c,i,k,l,n,m;

main(){cin>>n>>m;
       c=min(n,m);
       k=c+1;
       cout<<k<<endl;
       for(i=1;i<min(n,m)+1;i++) cout<<k-1<<" "<<i<<endl;

         }


#include<iostream>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;

int a[100],b[100],c,i,k,l,n,m;

main(){cin>>n>>m;
       c=min(n,m);
       k=c+1;
       cout<<k<<endl;
       for(i=0;i<min(n,m)+1;i++) cout<<k-1<<" "<<i<<endl;

       }


#include<iostream>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;

int a[100],b[100],c,i,k,l,n,m;

main(){cin>>n>>m;
       c=min(n,m);
       k=c+1;
       cout<<k<<endl;
       for(i=1;i<min(n,m)+1;i++) cout<<k-1<<" "<<i<<endl;

       }


#include<iostream>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;

int a[100],b[100],c,i,k,l,n,m;

main(){cin>>n>>m;
       c=min(n,m);
       k=c+1;
       cout<<k<<endl;
       for(i=1;i<min(n,m)+1;i++) {cout<<k-1<<" "<<i<<endl;
                                    k--;}

       }


#include<iostream>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;

int a[100],b[100],c,i,k,l,n,m;

main(){cin>>n>>m;
       c=min(n,m);
       k=c+1;
       cout<<k<<endl;
       for(i=0;i<min(n,m)+1;i++) {cout<<k-1<<" "<<i<<endl;
                                      k--;}

       }


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

const int MAXN = 5000 + 10;
map<int,int>  M;
int n, m, a[MAXN], b[MAXN];
int dp[MAXN][MAXN];

int main(){
  cin>>n>>m;
  double dd;
  for(int i=1;i<=n;i++){
    cin>>a[i]>>dd;
    b[i] = a[i];
  }
  sort(b+1, b+n+1);
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++){
      dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      if(a[i]==b[j])
	dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
    }
  cout<<n-dp[n][n]<<endl;
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int> > ans;
  if(n<m){
    cout<<n + 1<<endl;
    int x = 0;
    int y = 1;
    for(int x=0;x<=n;x++,y++){
      x = x%(n+1);
      y = y%(m+1);
      cout<<x<<' '<<y<<endl;
    }
  }
  else{
    cout<<m + 1<<endl;
    int x = 1;
    int y = 0;
    for(int y=0;y<=m;x++,y++){
      x = x%(n+1);
      y = y%(m+1);
      cout<<x<<' '<<y<<endl;
    }
  }
  return 0;
}


#include <iostream>
using namespace std;
int main(){
  int n, m;
  cin>>n>>m;
  int d = min(n, m);
  cout<<d+1<<endl;
  for(int i=0;i<d;i++)
    cout<<i<<' '<<i+1<<endl;
  if(n==d)
    cout<<d<<' '<<0<<endl;
  else
    cout<<0<<' '<<d<<endl;

  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int> > ans;
  if(n==m and n==0){
    cout<<0<<endl;
    return 0;
  }
  if(n<m){
    cout<<n + 1<<endl;
    int x = 0;
    int y = 1;
    for(int x=0;x<=n;x++,y++){
      x = x%(n+1);
      y = y%(m+1);
      cout<<x<<' '<<y<<endl;
    }
  }
  else{
    cout<<m + 1<<endl;
    int x = 1;
    int y = 0;
    for(int y=0;y<=m;x++,y++){
      x = x%(n+1);
      y = y%(m+1);
      cout<<x<<' '<<y<<endl;
    }
  }
  return 0;
}


#include <iostream>
using namespace std;
int main(){
  int n, m;
  cin>>n>>m;
  int d = min(n, m);
  cout<<d+1<<endl;
  for(int i=0;i<d;i++)
    if(n==d)
      cout<<i<<' '<<i+1<<endl;
    else
      cout<<i+1<<' '<<i<<endl;
  if(n==d)
    cout<<d<<' '<<0<<endl;
  else
    cout<<0<<' '<<d<<endl;

  return 0;
}


#include <iostream>
using namespace std;
int main(){
  int n, m;
  cin>>n>>m;
  int d = min(n, m);
  cout<<d+1<<endl;
  for(int i=d;i>=0;i--)
    cout<<d-i<<' '<<i<<endl;
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int> > ans;
  if(n<m){
    cout<<n + 1<<endl;
    int x = 0;
    int y = 1;
    for(int i=0;i<=n;i++,x++,y++){
      x = x%(n+1);
      y = y%(m+1);
      cout<<x<<' '<<y<<endl;
    }
  }
  else{
    cout<<m + 1<<endl;
    int x = 1;
    int y = 0;
    for(int i=0;i<=m;i++,x++,y++){
      x = x%(n+1);
      y = y%(m+1);
      cout<<x<<' '<<y<<endl;
    }
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

//Shortcuts
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define repd(i, a, b) for (int i = (a); i >= (b); --i)
#define fin(x) freopen(x, "r", stdin)
#define fout(x) freopen(x, "w", stdout)
#define sync ios_base::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define fs first
#define sd second

//Constants
#define inf (int)1e9
#define limt (int)1e3
#define eps 1e-6
#define slimt (int)1e7

int mark[limt][limt];
int perf[slimt];
int main()
{
   //fin("in.txt");
   sync;
   int n, m, ans = 0, x;
   cin >> n >> m;

   for (int i = 1; i * i < slimt; i++) perf[i * i] = 1;

   rep(i, 0, n + 1) {
      rep(j, 0, m + 1) {
         if (i + j > 0 && mark[i][j] == 0) {
            mark[i][j] = 1;
            ans++;
            rep(k, 0, n + 1) {
               rep(l, 0, m + 1) {
                  if (k != i || l != j) {
                     x = abs(k - i) * abs(k - i) + abs(l - j) * abs(l - j);
                     if (perf[x] == 1) mark[k][l] = -1;
                  }
               }
            }
         }
      }
   }
   cout << ans << endl;
   rep(i, 0, n + 1) {
      rep(j, 0, m + 1) {
         if (mark[i][j] == 1) {
            cout << i << " " << j << endl;
         }
      }
   }

   return 0;
}


#include <bits/stdc++.h>
using namespace std;

//Shortcuts
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define repd(i, a, b) for (int i = (a); i >= (b); --i)
#define fin(x) freopen(x, "r", stdin)
#define fout(x) freopen(x, "w", stdout)
#define sync ios_base::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define fs first
#define sd second

//Constants
#define inf (int)1e9
#define limt (int)1e3
#define eps 1e-6

int main()
{
   //fin("in.txt");
   sync;
   int n, m, ans;
   cin >> n >> m;
   ans = min(n, m) + 1;
   int x = max(n, m);
   int y = 0;
   cout << ans << endl;
   while (x >= 0) {
      cout << x-- << " " << y++ << endl;
   }

   return 0;
}


#include <bits/stdc++.h>
using namespace std;

//Shortcuts
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define repd(i, a, b) for (int i = (a); i >= (b); --i)
#define fin(x) freopen(x, "r", stdin)
#define fout(x) freopen(x, "w", stdout)
#define sync ios_base::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define fs first
#define sd second

//Constants
#define inf (int)1e9
#define limt (int)1e3
#define eps 1e-6

int main()
{
   //fin("in.txt");
   sync;
   int n, m, ans, f = 0;
   cin >> n >> m;
   ans = min(n, m) + 1;
   int x = max(n, m);
   int y = 0;
   if (x == n) f = 1;
   cout << ans << endl;
   while (ans--) {
      if (f) cout << x-- << " " << y++ << endl;
      else cout << y++ << " " << x-- << endl;
   }

   return 0;
}


#include <bits/stdc++.h>
using namespace std;

//Shortcuts
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define repd(i, a, b) for (int i = (a); i >= (b); --i)
#define fin(x) freopen(x, "r", stdin)
#define fout(x) freopen(x, "w", stdout)
#define sync ios_base::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define fs first
#define sd second

//Constants
#define inf (int)1e9
#define limt (int)1e3
#define eps 1e-6

int mark[limt][limt];
int main()
{
   //fin("in.txt");
   sync;
   int n, m, ans = 0;
   cin >> n >> m;

   rep(i, 0, n + 1) {
      rep(j, 0, m + 1) {
         if (i + j > 0 && mark[i][j] == 0) {
            mark[i][j] = 1;
            ans++;
            rep(k, j + 1, m + 1) mark[i][k] = -1;
            repd(k, j - 1, 0) mark[i][k] = -1;
            rep(k, i + 1, n + 1) mark[k][j] = -1;
            repd(k, i - 1, 0) mark[k][j] = -1;
         }
      }
   }
   cout << ans << endl;
   rep(i, 0, n + 1) {
      rep(j, 0, m + 1) {
         if (mark[i][j] == 1) {
            cout << i << " " << j << endl;
         }
      }
   }

   return 0;
}


#include <bits/stdc++.h>
using namespace std;

//Shortcuts
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define repd(i, a, b) for (int i = (a); i >= (b); --i)
#define fin(x) freopen(x, "r", stdin)
#define fout(x) freopen(x, "w", stdout)
#define sync ios_base::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define fs first
#define sd second

//Constants
#define inf (int)1e9
#define limt (int)1e3
#define eps 1e-6

int main()
{
   //fin("in.txt");
   sync;
   int n, m, ans;
   cin >> n >> m;
   ans = min(n, m) + 1;
   int x = max(n, m);
   int y = 0;
   cout << ans << endl;
   while (ans--) {
      cout << x-- << " " << y++ << endl;
   }

   return 0;
}


#include <bits/stdc++.h>
using namespace std;

//Shortcuts
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define repd(i, a, b) for (int i = (a); i >= (b); --i)
#define fin(x) freopen(x, "r", stdin)
#define fout(x) freopen(x, "w", stdout)
#define sync ios_base::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define fs first
#define sd second

//Constants
#define inf (int)1e9
#define limt (int)1e3
#define eps 1e-6

int main()
{
   //fin("in.txt");
   sync;
   int n, m, ans;
   cin >> n >> m;
   ans = min(n, m) + 1;
   int x = max(n, m);
   int y = 0;
   cout << ans << endl;
   while (ans--)) {
      cout << x-- << " " << y++ << endl;
   }

   return 0;
}


#include <bits/stdc++.h>
using namespace std;

//Shortcuts
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define repd(i, a, b) for (int i = (a); i >= (b); --i)
#define fin(x) freopen(x, "r", stdin)
#define fout(x) freopen(x, "w", stdout)
#define sync ios_base::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define fs first
#define sd second

//Constants
#define inf (int)1e9
#define limt (int)1e3
#define eps 1e-6

int main()
{
   //fin("in.txt");
   sync;
   int n, m, ans;
   cin >> n >> m;
   ans = min(n, m) + 1;
   int x = max(n, m);
   int y = 0;
   cout << ans << endl;
   while (ans--) {
      if (x == n) cout << x-- << " " << y++ << endl;
      else cout << y++ << " " << x-- << endl;
   }

   return 0;
}


#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>

#define inf 1000000000
#define ll long long
#define MXN 101

using namespace std;

int i, j, ans, n, m;
int x[20000], y[20000];
int n2, n1;

int main()
{
	//freopen("input.in", "r", stdin);
	//freopen("input.out", "w", stdout);
	//input

	cin>>n>>m;

	n1 = n;
	n2 = m;

	if (n1 < n2)
		swap(n, m);

	i = n;
	j = 0;

	while (i >= 0 && j <= m)
	{
		ans++;
		x[ans] = i;
		y[ans] = j;
		i--;
		j++;

	}

                if (n1 < n2)
                {
        cout<<ans<<endl;
        for (i = 1; i <= ans; i++)
        	cout<<y[i]<<" "<<x[i]<<endl;

        	}
        	else
        	{
        	cout<<ans<<endl;
        for (i = 1; i <= ans; i++)
        	cout<<x[i]<<" "<<y[i]<<endl;
        }
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>

#define inf 1000000000
#define ll long long
#define MXN 101

using namespace std;

int i, j, ans, n, m;
int x[20000], y[20000];

int main()
{
	//freopen("input.in", "r", stdin);
	//freopen("input.out", "w", stdout);
	//input

	cin>>n>>m;

	i = 0;
	j = 0;
	while (i <= n && j <= m)
	{
		ans++;
		x[ans] = i;
		y[ans] = j;
		i++;
		j++;
	}

        cout<<ans<<endl;
        for (i = 1; i <= ans; i++)
        	cout<<x[i]<<" "<<y[i]<<endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>

#define inf 1000000000
#define ll long long
#define MXN 101

using namespace std;

int i, j, ans, n, m;
int x[20000], y[20000];

int main()
{
	//freopen("input.in", "r", stdin);
	//freopen("input.out", "w", stdout);
	//input

	cin>>n>>m;

	i = 0;
	j = 1;
	while (i <= n && j <= m)
	{
		ans++;
		x[ans] = i;
		y[ans] = j;
		i++;
		j++;
	}
	ans++;
	x[ans] = n;
	y[ans] = 0;

        cout<<ans<<endl;
        for (i = 1;i<=ans;i++)
        	cout<<x[i]<<" "<<y[i]<<endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>

#define inf 1000000000
#define ll long long
#define MXN 101

using namespace std;

int i, j, ans, n, m;
int x[20000], y[20000];

int main()
{
	//freopen("input.in", "r", stdin);
	//freopen("input.out", "w", stdout);
	//input

	cin>>n>>m;

	i = n;
	j = 0;

	while (i && j <= m)
	{
		ans++;
		x[ans] = i;
		y[ans] = j;
		i--;
		j++;
	}

        cout<<ans<<endl;
        for (i = 1; i <= ans; i++)
        	cout<<x[i]<<" "<<y[i]<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
  int n,m;
  cin>>n>>m;
  cout<<min(n,m)+1<<endl;
   for(int i=0;i<=min(n,m);i++)
   {

       cout<<i <<i<<endl;
   }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
  int n,m;
  cin>>n>>m;
  cout<<min(n,m)+1<<endl;
   for(int i=1;i<=min(n,m);i++)
   {

       cout<<i<<" "<<i<<endl;
   }
   cout<<"0"<<" "<<"0";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
  int n,m;
  cin>>n>>m;
  cout<<min(n,m)+1<<endl;
   for(int i=1;i<min(n,m);i++)
   {

       cout<<i<<" "<<i<<endl;
   }
   cout<<"0"<<" "<<"0"<<endl;
   cout<<min(n,m)<<" "<<min(n,m);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
  int n,m;
  cin>>n>>m;
  cout<<min(n,m)+1<<endl;
  int y=min(n,m);
   for(int i=0;i<=min(n,m);i++)
   {

       cout<<i<<" "<<y-i<<endl;
   }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
  int n,m;
  cin>>n>>m;
  cout<<min(n,m)+1<<endl;
   for(int i=0;i<=min(n,m);i++)
   {

       cout<<i<<" "<<i<<endl;
   }
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#define lli long long int
#define pii pair<int,int>

using namespace std;

pii num[10005];
int n,m;

double dista(pii a,pii b){
    return sqrt(pow(a.first-b.first,2.0)+pow(a.second-b.second,2.0));
}

int calcula(int fin){
    bool flag,a;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            flag=true;
            for(int h=0;h<fin;h++){
                if((i!=num[h].first && j!=num[h].second) && int(dista(num[h],pii(i,j)))!=dista(num[h],pii(i,j)))
                    a=true;
                else
                    flag=false;
            }
            if(flag)
                num[fin++]=pii(i,j);
        }
    }
    return fin;
}

int main(){
    scanf("%d %d",&n,&m);
    int a=0,b=1;
    printf("%d\n",min(n,m)+1);
    int fin=0;
    while(b<=min(n,m)){
        num[fin++]=pii(a,b);
        a++;
        b++;
    }
    while(fin<min(n,m)+1){
        fin=calcula(fin);
    }
    for(int i=0;i<min(n,m)+1;i++)
        printf("%d %d\n",num[i].first,num[i].second);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#define lli long long int
#define pii pair<int,int>

using namespace std;

pii num[10005];
int n,m;

double dista(pii a,pii b){
    return sqrt(pow(a.first-b.first,2.0)+pow(a.second-b.second,2.0));
}

int calcula(int fin){
    bool flag,a;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            flag=true;
            for(int h=0;h<fin;h++){
                if((i!=num[h].first && j!=num[h].second) && int(dista(num[h],pii(i,j)))!=dista(num[h],pii(i,j)))
                    a=true;
                else
                    flag=false;
            }
            if(flag)
                num[fin++]=pii(i,j);
        }
    }
    return fin;
}

int main(){
    scanf("%d %d",&n,&m);
    int a=0,b=1;
    printf("%d\n",min(n,m)+1);
    int fin=0;
    while(b<=min(n,m)){
        num[fin++]=pii(a,b);
        a++;
        b++;
    }
    fin=calcula(fin);
    for(int i=0;i<min(n,m)+1;i++)
        printf("%d %d\n",num[i].first,num[i].second);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#define lli long long int
#define pii pair<int,int>

using namespace std;

pii num[10005];
int n,m;

double dista(pii a,pii b){
    return sqrt(pow(a.first-b.first,2.0)+pow(a.second-b.second,2.0));
}

int calcula(int fin){
    bool flag,a;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0 && j==0)continue;
            flag=true;
            for(int h=0;h<fin;h++){
                if((i!=num[h].first && j!=num[h].second) && int(dista(num[h],pii(i,j)))!=dista(num[h],pii(i,j)))
                    a=true;
                else
                    flag=false;
            }
            if(flag)
                num[fin++]=pii(i,j);
        }
    }
    return fin;
}

int main(){
    scanf("%d %d",&n,&m);
    int a=0,b=1;
    printf("%d\n",min(n,m)+1);
    int fin=0;
    while(b<=min(n,m)){
        num[fin++]=pii(a,b);
        a++;
        b++;
    }
    fin=calcula(fin);
    for(int i=0;i<min(n,m)+1;i++)
        if(num[i].first!=0 && num[i].second!=0)
            printf("%d %d\n",num[i].first,num[i].second);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#define lli long long int
#define pii pair<int,int>

using namespace std;

pii num[10005];
int n,m;

double dista(pii a,pii b){
    return sqrt(pow(a.first-b.first,2.0)+pow(a.second-b.second,2.0));
}

int calcula(int fin){
    bool flag,a;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            flag=true;
            for(int h=0;h<fin;h++){
                if((i!=num[h].first && j!=num[h].second) && int(dista(num[h],pii(i,j)))!=dista(num[h],pii(i,j)))
                    a=true;
                else
                    flag=false;
            }
            if(flag)
                num[fin++]=pii(i,j);
        }
    }
    return fin;
}

int main(){
    scanf("%d %d",&n,&m);
    int ini=0,fin=1;
    num[ini]=pii(0,1);
    while(ini<fin){
        fin=calcula(fin);
        ini++;
    }
    printf("%d\n",fin);
    for(int i=0;i<fin;i++)
        printf("%d %d\n",num[i].first,num[i].second);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#define lli long long int
#define pii pair<int,int>

using namespace std;

pii num[10005];
int n,m;

double dista(pii a,pii b){
    return sqrt(pow(a.first-b.first,2.0)+pow(a.second-b.second,2.0));
}

int calcula(int fin){
    bool flag,a;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0 && j==0)continue;
            flag=true;
            for(int h=0;h<fin;h++){
                if((i!=num[h].first && j!=num[h].second) && int(dista(num[h],pii(i,j)))!=dista(num[h],pii(i,j)))
                    a=true;
                else
                    flag=false;
            }
            if(flag)
                num[fin++]=pii(i,j);
        }
    }
    return fin;
}

int main(){
    scanf("%d %d",&n,&m);
    int a=0,b=1;
    printf("%d\n",min(n,m)+1);
    int fin=0;
    while(b<=min(n,m)){
        num[fin++]=pii(a,b);
        a++;
        b++;
    }
    fin=calcula(fin);
    for(int i=0;i<min(n,m)+1;i++)
        if(num[i].first!=0 || num[i].second!=0)
            printf("%d %d\n",num[i].first,num[i].second);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#define lli long long int
#define pii pair<int,int>

using namespace std;

pii num[10005];
int n,m;

int main(){
    scanf("%d %d",&n,&m);
    int a=0,b=0;
    printf("%d\n",min(n,m)+1);
    while(a<=min(n,m)){
        printf("%d %d\n",a,b);
        a++;
        b++;
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#define lli long long int
#define pii pair<int,int>

using namespace std;

pii num[10005];
int n,m;

double dista(pii a,pii b){
    return sqrt(pow(a.first-b.first,2.0)+pow(a.second-b.second,2.0));
}

int calcula(int fin){
    bool flag,a;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0 && j==0)continue;
            flag=true;
            for(int h=0;h<fin;h++){
                if((i!=num[h].first && j!=num[h].second) && int(dista(num[h],pii(i,j)))!=dista(num[h],pii(i,j)))
                    a=true;
                else
                    flag=false;
            }
            if(flag)
                num[fin++]=pii(i,j);
        }
    }
    return fin;
}

int main(){
    scanf("%d %d",&n,&m);
    int a=0,b=1;
    printf("%d\n",min(n,m)+1);
    int fin=0;
    while(b<=min(n,m)){
        num[fin++]=pii(a,b);
        a++;
        b++;
    }
    fin=calcula(fin);
    for(int i=0;i<min(n,m)+1;i++)
        printf("%d %d\n",num[i].first,num[i].second);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#define lli long long int
#define pii pair<int,int>

using namespace std;

pii num[10005];
int n,m;

int main(){
    scanf("%d %d",&n,&m);
    int a=n,b=min(n,m)-1;
    printf("%d\n",min(n,m)+1);
    for(int i=0;i<min(n,m)+1;i++)
        printf("%d %d\n",i,min(n,m)-i);
    return 0;
}


// In the name of God
// agn1360

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <conio.h>

using namespace std ;

typedef long long   LL ;
typedef long double LD ;

const int maxN=0 ;
const int minN=0 ;

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

   vector <int> X ;
   vector <int> Y ;

    X.push_back(1) ;
    X.push_back(0) ;
    Y.push_back(0) ;
    Y.push_back(1) ;

    for ( int i=2 ; i<= min(n,m) ; i++ )
    {
            X.push_back(i) ;
            Y.push_back(i) ;
    }

   cout << (int)X.size() << endl ;
   for ( int i=0 ; i< (int)X.size() ; i++ )
        cout << X[i] << " " << Y[i] << endl ;

    //getch() ;
    return 0 ;
}


// In the name of God
//dfs

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <conio.h>

using namespace std ;

typedef long long   LL ;
typedef long double LD ;

const int maxN=100001 ;

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

    cout << min(m,n)+1 << endl ;
    for ( int i=0 ; i<=n  &&  m>=0 ; i++ , m-- )
        cout << i << ' ' << m << endl ;

  //  getch() ;
    return 0 ;
}


// In the name of God
// agn1360

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <conio.h>

using namespace std ;

typedef long long   LL ;
typedef long double LD ;

const int maxN=0 ;
const int minN=0 ;

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

   vector <int> X ;
   vector <int> Y ;

   for ( int i=0 ; i<=n ; i++ )
   {
        for ( int j=0 ; j<=m ; j++ )
        {
             if ( i+j==0 )
                continue ;

             for ( int k=0 ; k< (int)X.size() ;  k++ )
             {
                float dis=sqrt( pow((float)i-X[k],2)  +  pow((float)j-Y[k],2) ) ;
                if ( int(dis)==dis )
                    goto line ;
             }
             X.push_back(i) ;
             Y.push_back(j) ;

             line: ;
        }
   }

   cout << (int)X.size() << endl ;
   for ( int i=0 ; i< (int)X.size() ; i++ )
        cout << X[i] << " " << Y[i] << endl ;

   // getch() ;
    return 0 ;
}


// In the name of God
// agn1360

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <conio.h>

using namespace std ;

typedef long long   LL ;
typedef long double LD ;

const int maxN=0 ;
const int minN=0 ;

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

   vector <int> X ;
   vector <int> Y ;

    X.push_back(1) ;
    X.push_back(0) ;
    Y.push_back(0) ;
    Y.push_back(1) ;

    for ( int i=2 ; i<= min(n,m) ; i++ )
    {
             for ( int k=0 ; k< (int)X.size() ;  k++ )
             {
                float dis=sqrt( pow((float)i-X[k],2)  +  pow((float)i-Y[k],2) ) ;
                if ( int(dis)==dis )
                    goto line ;
             }

            X.push_back(i) ;
            Y.push_back(i) ;

            line: ;
    }

   cout << (int)X.size() << endl ;
   for ( int i=0 ; i< (int)X.size() ; i++ )
        cout << X[i] << " " << Y[i] << endl ;

  //  getch() ;
    return 0 ;
}


// In the name of God
// agn1360

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <conio.h>

using namespace std ;

typedef long long   LL ;
typedef long double LD ;

const int maxN=0 ;
const int minN=0 ;

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

   vector <int> X ;
   vector <int> Y ;

   vector <int> XX ;
   vector <int> YY ;

    X.push_back(1) ;
    X.push_back(0) ;
    Y.push_back(0) ;
    Y.push_back(1) ;

    for ( int i=2 ; i<= n ; i++ )
    {
        for ( int j=0 ; j<= m ; j++ )
        {
             for ( int k=0 ; k< (int)X.size() ;  k++ )
             {
                float dis=sqrt( pow((float)i-X[k],2)  +  pow((float)j-Y[k],2) ) ;
                if ( int(dis)==dis )
                {
                    cout <<  "lkl " << i << " " << j   << endl ;
                    goto line ;
                }
             }

            X.push_back(i) ;
            Y.push_back(j) ;

            line: ;
        }
    }

   cout << (int)X.size() << endl ;
   for ( int i=0 ; i< (int)X.size() ; i++ )
        cout << X[i] << " " << Y[i] << endl ;

  //  getch() ;
    return 0 ;
}


// In the name of God
// agn1360

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <conio.h>

using namespace std ;

typedef long long   LL ;
typedef long double LD ;

const int maxN=0 ;
const int minN=0 ;

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

   vector <int> X ;
   vector <int> Y ;

    X.push_back(1) ;
    X.push_back(0) ;
    Y.push_back(0) ;
    Y.push_back(1) ;

    for ( int i=2 ; i<= min(n,m) ; i++ )
    {
            float dis=sqrt( pow((float)0-i,2)  +  pow((float)1-i,2) ) ;
            if ( int(dis)==dis )
                  continue ;

             dis=sqrt( pow((float)1-i,2)  +  pow((float)0-i,2) ) ;
            if ( int(dis)==dis )
                continue ;
            X.push_back(i) ;
            Y.push_back(i) ;
    }

   cout << (int)X.size() << endl ;
   for ( int i=0 ; i< (int)X.size() ; i++ )
        cout << X[i] << " " << Y[i] << endl ;

  //  getch() ;
    return 0 ;
}


// In the name of God
// agn1360

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <conio.h>

using namespace std ;

typedef long long   LL ;
typedef long double LD ;

const int maxN=0 ;
const int minN=0 ;

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

   vector <int> X ;
   vector <int> Y ;

   vector <int> XX ;
   vector <int> YY ;

    X.push_back(1) ;
    X.push_back(0) ;
    Y.push_back(0) ;
    Y.push_back(1) ;

    for ( int i=2 ; i<= n ; i++ )
    {
        for ( int j=0 ; j<= m ; j++ )
        {
             for ( int k=0 ; k< (int)X.size() ;  k++ )
             {
                float dis=sqrt( pow((float)i-X[k],2)  +  pow((float)j-Y[k],2) ) ;
                if ( int(dis)==dis )
                {
                   //cout <<  "lkl " << i << " " << j   << endl ;
                    goto line ;
                }
             }

            X.push_back(i) ;
            Y.push_back(j) ;

            line: ;
        }
    }

   cout << (int)X.size() << endl ;
   for ( int i=0 ; i< (int)X.size() ; i++ )
        cout << X[i] << " " << Y[i] << endl ;

  //  getch() ;
    return 0 ;
}


#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, string > is;
typedef pair<string, string > ss;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define FF ios_base::sync_with_stdio(false)
#define rep(i, a, o) \
for (int i = int(a); i <= int(o); i++) // a to o, and variaole i is local!
#define Drep(i, a, o) \
for (int i = int(a); i >= int(o); i--) // a to o, and variaole i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).oegin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).oegin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).oegin(); it != (c).end(); it++)
#define INF 2000000000 // 2 oillion
#define MEMSET_INF 127 // aoout 2o
#define PI 3.1415926536
#define MEMSET_HALF_INF 63 // aoout 1o
int main()
{
    int  n , m , i=1 , j ;
    cin >> n >> m ;
    /*for(i=0,j=1,k=0;j<=max(n,m) && k <= min(n,m);j++,i++,k++)
    {
        cout << k << " " << j <<endl ;
        k++;
        if(k > min(n,m))break ;
        cout << k << " " << i << endl ;
    }*/
    if(n == m && n == 0 ){cout << 0 << endl ; return 0 ;}
    cout << min(n,m)<<endl ;
    rep(k,0,min(n-1,m-1))
    {
        cout << k << " " << i <<endl ;;
        i++;
    }
    cout << min(n,m) << " " << 0 <<endl ;
}


#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, string > is;
typedef pair<string, string > ss;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define FF ios_base::sync_with_stdio(false)
#define rep(i, a, o) \
for (int i = int(a); i <= int(o); i++) // a to o, and variaole i is local!
#define Drep(i, a, o) \
for (int i = int(a); i >= int(o); i--) // a to o, and variaole i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).oegin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).oegin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).oegin(); it != (c).end(); it++)
#define INF 2000000000 // 2 oillion
#define MEMSET_INF 127 // aoout 2o
#define PI 3.1415926536
#define MEMSET_HALF_INF 63 // aoout 1o
int main()
{
    int  n , m , i=1 , j ;
    cin >> n >> m ;
    /*for(i=0,j=1,k=0;j<=max(n,m) && k <= min(n,m);j++,i++,k++)
    {
        cout << k << " " << j <<endl ;
        k++;
        if(k > min(n,m))break ;
        cout << k << " " << i << endl ;
    }*/
    rep(k,0,min(n-1,m-1))
    {
        cout << k << " " << i <<endl ;;
        i++;
    }
    cout << min(n,m) << " " << 0 <<endl ;
}


#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, string > is;
typedef pair<string, string > ss;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define FF ios_base::sync_with_stdio(false)
#define rep(i, a, o) \
for (int i = int(a); i <= int(o); i++) // a to o, and variaole i is local!
#define Drep(i, a, o) \
for (int i = int(a); i >= int(o); i--) // a to o, and variaole i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).oegin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).oegin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).oegin(); it != (c).end(); it++)
#define INF 2000000000 // 2 oillion
#define MEMSET_INF 127 // aoout 2o
#define PI 3.1415926536
#define MEMSET_HALF_INF 63 // aoout 1o
int main()
{
    lli n , m ;
    cin >> n >> m ;
    if(n == m && m==0 )
    {
        cout <<0 ;
        return 0 ;
    }
    cout << min(n,m)+1 <<endl ;
    lli i  =0 , j = max(n,m)  , k = 0;
    while(k <= n)
    {
        cout << k << " " << i <<endl;        if( i == j )break ;

        k++,i++;
        cout << k << " " << j << endl ;
        k++,j--;
    }
}


#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, string > is;
typedef pair<string, string > ss;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define FF ios_base::sync_with_stdio(false)
#define rep(i, a, o) \
for (int i = int(a); i <= int(o); i++) // a to o, and variaole i is local!
#define Drep(i, a, o) \
for (int i = int(a); i >= int(o); i--) // a to o, and variaole i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).oegin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).oegin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).oegin(); it != (c).end(); it++)
#define INF 2000000000 // 2 oillion
#define MEMSET_INF 127 // aoout 2o
#define PI 3.1415926536
#define MEMSET_HALF_INF 63 // aoout 1o
int main()
{
    int  n , m , i=0 , j ;
    cin >> n >> m ;
    /*for(i=0,j=1,k=0;j<=max(n,m) && k <= min(n,m);j++,i++,k++)
    {
        cout << k << " " << j <<endl ;
        k++;
        if(k > min(n,m))break ;
        cout << k << " " << i << endl ;
    }*/
    if(n == m && n == 0 ){cout << 0 << endl ; return 0 ;}
    cout << min(n,m)+1<<endl ;
    Drep(k,min(n,m),0)
    {
        cout << k << " " << i <<endl ;;
        i++;
    }
   // cout << min(n,m) << " " << 0 <<endl ;
}


#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, string > is;
typedef pair<string, string > ss;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define FF ios_base::sync_with_stdio(false)
#define rep(i, a, o) \
for (int i = int(a); i <= int(o); i++) // a to o, and variaole i is local!
#define Drep(i, a, o) \
for (int i = int(a); i >= int(o); i--) // a to o, and variaole i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).oegin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).oegin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).oegin(); it != (c).end(); it++)
#define INF 2000000000 // 2 oillion
#define MEMSET_INF 127 // aoout 2o
#define PI 3.1415926536
#define MEMSET_HALF_INF 63 // aoout 1o
int main()
{
    int  n , m , i=1 , j ;
    cin >> n >> m ;
    /*for(i=0,j=1,k=0;j<=max(n,m) && k <= min(n,m);j++,i++,k++)
    {
        cout << k << " " << j <<endl ;
        k++;
        if(k > min(n,m))break ;
        cout << k << " " << i << endl ;
    }*/
    if(n == m && n == 0 ){cout << 0 << endl ; return 0 ;}
    cout << min(n,m)+1<<endl ;
    rep(k,0,min(n-1,m-1))
    {
        cout << k << " " << i <<endl ;;
        i++;
    }
    cout << min(n,m) << " " << 0 <<endl ;
}


#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, string > is;
typedef pair<string, string > ss;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define FF ios_base::sync_with_stdio(false)
#define rep(i, a, o) \
for (int i = int(a); i <= int(o); i++) // a to o, and variaole i is local!
#define Drep(i, a, o) \
for (int i = int(a); i >= int(o); i--) // a to o, and variaole i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).oegin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).oegin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).oegin(); it != (c).end(); it++)
#define INF 2000000000 // 2 oillion
#define MEMSET_INF 127 // aoout 2o
#define PI 3.1415926536
#define MEMSET_HALF_INF 63 // aoout 1o
int main()
{
    FF;
    cin.tie(false) ;
    int  n , m , i=0 , j ;
    cin >> n >> m ;
    /*for(i=0,j=1,k=0;j<=max(n,m) && k <= min(n,m);j++,i++,k++)
    {
        cout << k << " " << j <<endl ;
        k++;
        if(k > min(n,m))break ;
        cout << k << " " << i << endl ;
    }*/
    if(n == m && n == 0 ){cout << 0 << endl ; return 0 ;}
    cout << min(n,m)+1<<endl ;
    Drep(k,min(n,m),0)
    {
        cout << k << " " << i <<endl ;;
        i++;
    }
   // cout << min(n,m) << " " << 0 <<endl ;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <cmath>

#define MAX(a,b) (((a) > (b))? (a) : (b))
#define MIN(a,b) (((a) < (b))? (a) : (b))
#define MEM(a,b) (memset((a),(b),sizeof(a)))
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define f1 first
#define f2 second
#define X first
#define Y second

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <LL,LL> PLL;

const int Maxn = 100*1000 + 25;
const int Mod = 1000 * 1000 * 1000 + 7;

//ofstream fout ("greetings.out");
//ifstream fin ("greetings.in");

int N,M,tmp;

int main()
{
	ios::sync_with_stdio(0);
	cin >> N >> M;
	tmp=MIN(M+1,N+1);
	cout << tmp << endl;
	FOR (i,1,tmp)
	{
	    cout << i << ' ' << i << endl;
	}
	cout << 0 << ' ' << 0 << end;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <cmath>

#define MAX(a,b) (((a) > (b))? (a) : (b))
#define MIN(a,b) (((a) < (b))? (a) : (b))
#define MEM(a,b) (memset((a),(b),sizeof(a)))
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define f1 first
#define f2 second
#define X first
#define Y second

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <LL,LL> PLL;

const int Maxn = 100*1000 + 25;
const int Mod = 1000 * 1000 * 1000 + 7;

//ofstream fout ("greetings.out");
//ifstream fin ("greetings.in");

int N,M,tmp;

int main()
{
	ios::sync_with_stdio(0);
	cin >> N >> M;
	tmp=MIN(M+1,N+1);
	cout << tmp << endl;
	FOR (i,0,tmp)
	{
	    cout << i << ' ' << tmp-i-1 << endl;
	}
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <cmath>

#define MAX(a,b) (((a) > (b))? (a) : (b))
#define MIN(a,b) (((a) < (b))? (a) : (b))
#define MEM(a,b) (memset((a),(b),sizeof(a)))
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define f1 first
#define f2 second
#define X first
#define Y second

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <LL,LL> PLL;

const int Maxn = 100*1000 + 25;
const int Mod = 1000 * 1000 * 1000 + 7;

//ofstream fout ("greetings.out");
//ifstream fin ("greetings.in");

int N,M,tmp;

int main()
{
	ios::sync_with_stdio(0);
	cin >> N >> M;
	tmp=MIN(M+1,N+1);
	cout << tmp << endl;
	FOR (i,0,tmp)
	{
	    cout << i << ' ' << tmp-i << endl;
	}
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <cmath>

#define MAX(a,b) (((a) > (b))? (a) : (b))
#define MIN(a,b) (((a) < (b))? (a) : (b))
#define MEM(a,b) (memset((a),(b),sizeof(a)))
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define f1 first
#define f2 second
#define X first
#define Y second

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <LL,LL> PLL;

const int Maxn = 100*1000 + 25;
const int Mod = 1000 * 1000 * 1000 + 7;

//ofstream fout ("greetings.out");
//ifstream fin ("greetings.in");

int N,M,tmp;

int main()
{
	ios::sync_with_stdio(0);
	cin >> N >> M;
	tmp=MIN(M+1,N+1);
	cout << tmp << endl;
	FOR (i,0,tmp)
	{
	    cout << i << ' ' << i << endl;
	}
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <cmath>

#define MAX(a,b) (((a) > (b))? (a) : (b))
#define MIN(a,b) (((a) < (b))? (a) : (b))
#define MEM(a,b) (memset((a),(b),sizeof(a)))
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define f1 first
#define f2 second
#define X first
#define Y second

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <LL,LL> PLL;

const int Maxn = 100*1000 + 25;
const int Mod = 1000 * 1000 * 1000 + 7;

//ofstream fout ("greetings.out");
//ifstream fin ("greetings.in");

int N,M,tmp;

int main()
{
	ios::sync_with_stdio(0);
	cin >> N >> M;
	tmp=MIN(M+1,N+1);
	cout << tmp << endl;
	FOR (i,1,tmp)
	{
	    cout << i << ' ' << i << endl;
	}
	cout << 0 << ' ' << 0 << endl;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <cmath>

#define MAX(a,b) (((a) > (b))? (a) : (b))
#define MIN(a,b) (((a) < (b))? (a) : (b))
#define MEM(a,b) (memset((a),(b),sizeof(a)))
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define f1 first
#define f2 second
#define X first
#define Y second

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <LL,LL> PLL;

const int Maxn = 100*1000 + 25;
const int Mod = 1000 * 1000 * 1000 + 7;

//ofstream fout ("greetings.out");
//ifstream fin ("greetings.in");

LL N,M,tmp;

int main()
{
	ios::sync_with_stdio(0);
	cin >> N >> M;
	tmp=MIN(M+1,N+1);
	cout << tmp << endl;
	FOR (i,0,tmp)
	{
	    cout << i << ' ' << i << endl;
	}
}


#include <cstdio>
int n,m,i;
int main (){
    scanf("%d %d",&n,&m);
    if (n>m){
        printf("%d\n",m+1);
        for (i=0;i<=m;i++) printf("%d %d\n",i+1,i);
    } else if (n==m){
        printf("%d\n",n+1);
        for (i=0;i<=n;i++) printf("%d %d\n",i,n-i);
    } else {
        printf("%d\n",n+1);
        for (i=0;i<=n;i++) printf("%d %d\n",i,i+1);
    }
    return 0;
}


#include <cstdio>
int n,m,i;
int main (){
    scanf("%d %d",&n,&m);
    if (n>m){
        printf("%d\n",m+1);
        for (i=0;i<=m;i++) printf("%d %d\n",i+1,i);
    } else if (n==m){
        printf("%d\n",n+1);
        for (i=0;i<=n;i++) printf("%d %d\n",i,(i+n/2)%(n+1));
    } else {
        printf("%d\n",n+1);
        for (i=0;i<=n;i++) printf("%d %d\n",i,i+1);
    }
    return 0;
}


#include <cstdio>
int n,m,i;
int main (){
    scanf("%d %d",&n,&m);
    if (n>m){
        printf("%d\n",m+1);
        for (i=0;i<=m;i++) printf("%d %d\n",i+1,i);
    } else if (n==m){
        printf("%d\n",n+1);
        for (i=0;i<=n;i++) printf("%d %d\n",i,(i+n/2)%n);
    } else {
        printf("%d\n",n+1);
        for (i=0;i<=n;i++) printf("%d %d\n",i,i+1);
    }
    return 0;
}


#include <cstdio>
int n,m,i;
int main (){
    scanf("%d %d",&n,&m);
    if (n>m){
        printf("%d\n",m+1);
        for (i=0;i<=m;i++) printf("%d %d\n",i+1,i);
    } else if (n==m){
        printf("%d\n",n+1);
        for (i=0;i<n;i++) printf("%d %d\n",i,i+1);
        printf("%d 0\n",n);
    } else {
        printf("%d\n",n+1);
        for (i=0;i<=n;i++) printf("%d %d\n",i,i+1);
    }
    return 0;
}


#include <cstdio>
int n,m,i;
int main (){
    scanf("%d %d",&n,&m);
    if (n>m){
        printf("%d\n",n);
        for (i=1;i<=n;i++) printf("%d %d\n",i,i-1);
    } else if (n==m){
        printf("%d\n",n+1);
        for (i=0;i<n;i++) printf("%d %d\n",i,i+1);
        printf("%d 0\n",n);
    } else {
        printf("%d\n",m);
        for (i=1;i<=m;i++) printf("%d %d\n",i-1,i);
    }
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n,m,i,j;
cin>>n>>m;
int k;
if(n<m)
{
k=n+1;
cout<<k<<endl;
for(i=0;i<=n;i++)
cout<<i<<" "<<i+1<<endl;
}
else
{
k=m+1;
cout<<k<<endl;
for(i=0;i<=m;i++)
cout<<i+1<<" "<<i<<endl;
}
//cout<<n<<" "<<0<<endl;
return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n,m,i,j;
cin>>n>>m;
int k=min(n,m)+1;
cout<<k<<endl;
for(i=0;i<k-1;i++)
cout<<i<<" "<<i+1<<endl;
cout<<n<<" "<<0<<endl;
return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int arr[500000];
int main()
{
int n,m,i,j;
cin>>n>>m;
int k;
if(n<m)
{
k=n+1;
cout<<k<<endl;
for(i=0;i<=n;i++)
cout<<i<<" "<<i+1<<endl;
}
else if(n>m)
{
k=m+1;
cout<<k<<endl;
for(i=0;i<=m;i++)
cout<<i+1<<" "<<i<<endl;
}
else
{
k=n+1;
//cout<<k<<endl;
//for(i=0;i<n;i++)
//cout<<i<<" "<<i+1<<endl;
//cout<<n<<" "<<"0"<<endl;
for(i=0;i<=500;i++)
arr[i*i]=1;
for(i=n-1;i>=0;i--)
{
bool b=true;
for(j=0;j<n;j++)
{
if(arr[(n-j)*(n-j)+(j+1-i)*(j+1-i)]==0)
{
}
else
b=false;
}
if(b)
{
int x=i;
cout<<k<<endl;
for(i=0;i<n;i++)
cout<<i<<" "<<i+1<<endl;
cout<<n<<" "<<x<<endl;
return 0;
}
}
cout<<k-1<<endl;
for(i=0;i<n;i++)
cout<<i<<" "<<i+1<<endl;
}
//cout<<n<<" "<<0<<endl;
return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int arr[500000];
int main()
{
int n,m,i,j;
cin>>n>>m;
int k;
if(n<m)
{
k=n+1;
cout<<k<<endl;
for(i=0;i<=n;i++)
cout<<i<<" "<<i+1<<endl;
}
else if(n>m)
{
k=m+1;
cout<<k<<endl;
for(i=0;i<=m;i++)
cout<<i+1<<" "<<i<<endl;
}
else
{
k=n+1;
//cout<<k<<endl;
//for(i=0;i<n;i++)
//cout<<i<<" "<<i+1<<endl;
//cout<<n<<" "<<"0"<<endl;
for(i=0;i<=500;i++)
arr[i*i]=1;
for(i=n-1;i>=0;i--)
{
bool b=true;
for(j=0;j<n;j++)
{
if(arr[(n-j)*(n-j)+(j+1-i)*(j+1-i)]==0)
{
}
else
b=false;
}
if(b)
{
cout<<k<<endl;
for(i=0;i<n;i++)
cout<<i<<" "<<i+1<<endl;
cout<<n<<" "<<i<<endl;
return 0;
}
}
cout<<k-1<<endl;
for(i=0;i<n;i++)
cout<<i<<" "<<i+1<<endl;
}
//cout<<n<<" "<<0<<endl;
return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int arr[500000];
int main()
{
int n,m,i,j;
cin>>n>>m;
int k;
if(n<m)
{
k=n+1;
cout<<k<<endl;
for(i=0;i<=n;i++)
cout<<i<<" "<<i+1<<endl;
}
else if(n>m)
{
k=m+1;
cout<<k<<endl;
for(i=0;i<=m;i++)
cout<<i+1<<" "<<i<<endl;
}
else
{
k=n+1;
cout<<k<<endl;
for(i=n;i>=0;i--)
cout<<i<<" "<<n-i<<endl;
//cout<<n<<" "<<"0"<<endl;
}
return 0;

}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n,m,i,j;
cin>>n>>m;
int k;
if(n<m)
{
k=n+1;
cout<<k<<endl;
for(i=0;i<=n;i++)
cout<<i<<" "<<i+1<<endl;
}
else if(m>n)
{
k=m+1;
cout<<k<<endl;
for(i=0;i<=m;i++)
cout<<i+1<<" "<<i<<endl;
}
else
{
k=n+1;
cout<<k<<endl;
for(i=0;i<n;i++)
cout<<i<<" "<<i+1<<endl;
cout<<n<<" "<<"0"<<endl;
}
//cout<<n<<" "<<0<<endl;
return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n,m,i,j;
cin>>n>>m;
int k=min(n,m)+1;
cout<<k<<endl;
for(i=0;i<k;i++)
cout<<i<<" "<<i<<endl;
return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int arr[500000];
int main()
{
int n,m,i,j;
cin>>n>>m;
int k;
if(n<m)
{
k=n+1;
cout<<k<<endl;
for(i=0;i<=n;i++)
cout<<i<<" "<<i+1<<endl;
}
else if(n>m)
{
k=m+1;
cout<<k<<endl;
for(i=0;i<=m;i++)
cout<<i+1<<" "<<i<<endl;
}
else
{
k=n+1;
cout<<k<<endl;
for(i=0;i<n;i++)
cout<<i<<" "<<i+1<<endl;
//cout<<n<<" "<<"0"<<endl;
for(i=0;i<=500;i++)
arr[i*i]=1;
for(i=n-1;i>=0;i--)
{
bool b=true;
for(j=0;j<n;j++)
{
if(arr[(n-j)*(n-j)+(j+1-i)*(j+1-i)]==0)
{
}
else
b=false;
}
if(b)
{
cout<<n<<" "<<i<<endl;
return 0;
}
}
}
//cout<<n<<" "<<0<<endl;
return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n,m,i,j;
cin>>n>>m;
int k;
if(n<m)
{
k=n+1;
cout<<k<<endl;
for(i=0;i<=n;i++)
cout<<i<<" "<<i+1<<endl;
}
else if(n>m)
{
k=m+1;
cout<<k<<endl;
for(i=0;i<=m;i++)
cout<<i+1<<" "<<i<<endl;
}
else
{
k=n+1;
cout<<k<<endl;
for(i=0;i<n;i++)
cout<<i<<" "<<i+1<<endl;
cout<<n<<" "<<"0"<<endl;
}
//cout<<n<<" "<<0<<endl;
return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
    int n,m,k;
    cin>>n>>m;
    if(n<m) swap(n,m);
    k=m+1;
    cout<<k<<endl;
    for(int i=0;i<=m;i++)
    {
        if(i>=(m/2)) cout<<i-1<<' '<<i<<endl;
        else cout<<k-i<<' '<<i<<endl;
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
    int n,m,k;
    cin>>n>>m;
    if(n<m) swap(n,m);
    k=m+1;
    cout<<k<<endl;
    for(int i=0;i<=m;i++)
        cout<<m-i<<' '<<i<<endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
    int n,m,k;
    cin>>n>>m;
    if(n<m) swap(n,m);
    k=m+1;
    cout<<k<<endl;
    for(int i=0;i<=m;i++)
    {
        if(i>=(m/2)) cout<<i-1<<' '<<i<<endl;
        else cout<<m-i<<' '<<i<<endl;
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
    int n,m,k;
    cin>>n>>m;
    if(n<m) swap(n,m);
    k=m+1;
    cout<<k<<endl;
    cout<<m<<' '<<0<<endl;
    for(int i=1;i<=m;i++)
    {
        cout<<i-1<<' '<<i<<endl;

    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define eps 1e-10
struct Point
{
    int x,y;
}p[150];
int main()
{
    int n,m,k;
    cin>>n>>m;
    if(n<m) swap(n,m);

    for(int i=0;i<m;i++)
    {
        p[i].x=i;
        p[i].y=i+1;

    }
    int flag=1;
    for(int i=0;i<m;i++)
    {
        double kk=sqrt((m-p[i].x)*(m-p[i].x)+p[i].y*p[i].y);
        if(kk-int(kk)<eps) {flag=0;break;}

    }
    //cout<<flag<<endl;
    if(flag) k=m+1;
    else k=m;
    cout<<k<<endl;
    for(int i=0;i<m;i++)
        cout<<p[i].x<<' '<<p[i].y<<endl;
    if(flag)
        cout<<m<<' '<<0<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
    int n,m,k;
    cin>>n>>m;
    if(n<m) swap(n,m);
    k=m+1;
    cout<<k<<endl;
    for(int i=0;i<=m;i++)
    {
        cout<<i<<' '<<i<<endl;

    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
    int n,m,k;
    cin>>n>>m;
    if(n<m) swap(n,m);
    k=m;
    cout<<k<<endl;
    for(int i=0;i<=m;i++)
        cout<<m-i<<' '<<i<<endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define eps 1e-10
struct Point
{
    int x,y;
}p[150];
int main()
{
    int n,m,k;
    cin>>n>>m;
    if(n<m) swap(n,m);

    for(int i=0;i<m;i++)
    {
        p[i].x=i;
        p[i].y=i+1;

    }
    int flag,j;
    for(j=m;j<=n;j++)
    {
        flag=1;
        for(int i=0;i<j;i++)
        {
            double kk=sqrt((j-p[i].x)*(j-p[i].x)+p[i].y*p[i].y);
            if(kk-int(kk)<eps) {flag=0;break;}

        }
        if(flag) break;
    }
    //cout<<flag<<endl;
    if(flag) k=m+1;
    else k=m;
    cout<<k<<endl;
    for(int i=0;i<m;i++)
        cout<<p[i].x<<' '<<p[i].y<<endl;
    if(flag)
        cout<<j<<' '<<0<<endl;
    return 0;
}


#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
using namespace std;
int main(){
    int  n,m,i,q;
    cin >> n>>m;
    if(n>m) {q=m+1;} else {q=n+1;}
    cout << q<<"\n";
    for (i=0; i<q; i++) cout <<i<<" "<<q-i-1<<"\n";
    return 0;
     }


#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
using namespace std;
int main(){
    int  n,m,i,q;
    cin >> n>>m;
    if(n>m) {q=m+1;} else {q=n+1;}
    cout << q<<"\n";
    for (i=0; i<q-1; i++) cout <<i+1<<" "<<i<<"\n";
    cout <<0<<" "<<q-1<<"\n";
   // system("pause");
    return 0;
     }


#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
using namespace std;
int main(){
    int  n,m,i,q;
    cin >> n>>m;
    if(n>m) {q=m+1;} else {q=n+1;}
    cout << q<<"\n";
    for (i=0; i<q; i++) cout <<i<<" "<<i<<"\n";
  //  system("pause");
    return 0;
     }


#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
using namespace std;
int main(){
    int  n,m,i,q;
    cin >> n>>m;
    if(n>m) {q=m+1;} else {q=n+1;}
    if (n==0 and m==0) cout <<0<<"\n"; else cout << q<<"\n";
    for (i=0; i<q-1; i++) cout <<i+1<<" "<<i<<"\n";
    if (n==0 and m!=0) cout <<0<<" "<<1<<"\n";
    if (n!=0 and m==0)cout<<1<<" "<<0<<"\n";
    if (n!=0 and m!=0)cout <<0<<" "<<q-1<<"\n";
   system("pause");
    return 0;
     }


#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
using namespace std;
int main(){
    int  n,m,i,q;
    cin >> n>>m;
    if(n>m) {q=m+1;} else {q=n+1;}
    if (n==0 and m==0) {cout<<0<<"\n";} else {cout << q<<"\n";
    for (i=0; i<q-1; i++) cout <<i+1<<" "<<i<<"\n";
    if (n==0) {cout <<0<<" "<<1<<"\n";} else {
              if (m==0) {cout<<1<<" "<<0<<"\n";} else
              {cout <<0<<" "<<q-1<<"\n";}}
              }
    system("pause");
    return 0;
     }


     #include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
using namespace std;
int main(){
    int  n,m,i,q;
    cin >> n>>m;
    if(n>m) {q=m+1;} else {q=n+1;}
    if (n==0 and m==0)cout<<0<<"\n"; else {cout << q<<"\n";
    for (i=0; i<q-1; i++) cout <<i+1<<" "<<i<<"\n";
    if (n==0) cout <<0<<" "<<1<<"\n"; else {
              if (m==0) cout<<1<<" "<<0<<"\n"; else
              cout <<0<<" "<<q-1<<"\n";}
              }
    system("pause");
    return 0;
     }


#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
using namespace std;
int main(){
    int  n,m,i,q;
    cin >> n>>m;
    if(n>m) {q=m+1;} else {q=n+1;}
    if (n==0 and m==0) cout <<0<<"\n"; else cout << q<<"\n";
    for (i=0; i<q-1; i++) cout <<i+1<<" "<<i<<"\n";
    if ((n==0) and (m!=0)) cout <<0<<" "<<1<<"\n";
    if ((n!=0) and (m==0))cout<<1<<" "<<0<<"\n";
    if ((n!=0) and (m!=0))cout <<0<<" "<<q-1<<"\n";
   system("pause");
    return 0;
     }


#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef vector<ll> vin;
typedef vector<string> vs;
typedef vector<vector<ll> > vvin;

#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define inf 1000000000
#define mp make_pair
#define sz size()
#define all(vec) (vec).begin(),(vec).end()

/*
bool compare(const char &a, const char &b)
{
    return a<b;
}

ll fastexp(ll base, ll exp)
{
    if(exp==0) return 1;
    if(exp==1) return base;

    ll ans = fastexp(base, exp/2);

    return ans*ans*fastexp(base, exp%2);
}

ll gcd(ll a, ll b)
{
    if(a==0) return b;
    if(b==0) return a;

    if(a>b) return gcd(a%b, b);
    else return gcd(a, b%a);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a,b);
}
*/

int N;

int ans(int n)
{
    if(n==1)
    return 1;

    return (N-n+1)*(n-1)+1+ans(n-1);
}

int main()
{
    int n, m, dep;

    cin>>n>>m;

    dep = min(n, m);

        cout<<dep+1<<endl;

        if(dep==m) {
        rep(i,dep)
        if(dep==6&&i==1)cout<<"1 0\n";
        else cout<<i<<" "<<i+1<<endl;
        if(dep!=6)
        cout<<dep<<" 0\n";
        else cout<<dep<<" 2\n";
        }
        else {
        rep(i,dep)
        if(dep==6&&i==1)cout<<"0 1\n";
        else cout<<i+1<<" "<<i<<endl;
        if(dep!=6)
        cout<<"0 "<<dep<<endl;
        else cout<<"2 "<<dep<<endl;
        }
    /*

    int dep = min(n,m);
    int las = max(n,m);

    cout<<dep+1<<endl;

    REP(i,1,dep+1)
    cout<<i<<" "<<i<<endl;
    if(las==n)
    cout<<las<<" 0"<<endl;
    else cout<<"0 "<<las<<endl;
    */

    return 0;
}


#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef vector<ll> vin;
typedef vector<string> vs;
typedef vector<vector<ll> > vvin;

#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define inf 1000000000
#define mp make_pair
#define sz size()
#define all(vec) (vec).begin(),(vec).end()

/*
bool compare(const char &a, const char &b)
{
    return a<b;
}

ll fastexp(ll base, ll exp)
{
    if(exp==0) return 1;
    if(exp==1) return base;

    ll ans = fastexp(base, exp/2);

    return ans*ans*fastexp(base, exp%2);
}

ll gcd(ll a, ll b)
{
    if(a==0) return b;
    if(b==0) return a;

    if(a>b) return gcd(a%b, b);
    else return gcd(a, b%a);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a,b);
}
*/

int N;

int ans(int n)
{
    if(n==1)
    return 1;

    return (N-n+1)*(n-1)+1+ans(n-1);
}

int main()
{
    int n, m;

    cin>>n>>m;

    if(n==m)
    {
        cout<<n+1<<endl;
        rep(i,n)
        cout<<i<<" "<<i+1<<endl;
        cout<<n<<" 0\n";
        return 0;
    }

    int dep = min(n,m);
    int las = max(n,m);

    cout<<dep+1<<endl;

    REP(i,1,dep+1)
    cout<<i<<" "<<i<<endl;
    if(las==n)
    cout<<las<<" 0"<<endl;
    else cout<<"0 "<<las<<endl;

    return 0;
}


#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef vector<ll> vin;
typedef vector<string> vs;
typedef vector<vector<ll> > vvin;

#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define inf 1000000000
#define mp make_pair
#define sz size()
#define all(vec) (vec).begin(),(vec).end()

/*
bool compare(const char &a, const char &b)
{
    return a<b;
}

ll fastexp(ll base, ll exp)
{
    if(exp==0) return 1;
    if(exp==1) return base;

    ll ans = fastexp(base, exp/2);

    return ans*ans*fastexp(base, exp%2);
}

ll gcd(ll a, ll b)
{
    if(a==0) return b;
    if(b==0) return a;

    if(a>b) return gcd(a%b, b);
    else return gcd(a, b%a);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a,b);
}
*/

int N;

int ans(int n)
{
    if(n==1)
    return 1;

    return (N-n+1)*(n-1)+1+ans(n-1);
}

int main()
{
    int n, m, dep;

    cin>>n>>m;

    dep = min(n, m);

        cout<<dep+1<<endl;

        if(dep==m) {
        REP(i,0,dep)
        if(i==1)cout<<"1 0\n";
        else cout<<i<<" "<<i+1<<endl;
        cout<<dep+1<<" 2\n";
        }
        else {
        REP(i,0,dep)
        if(i+1==2) cout<<"0 1\n";
        else cout<<i+1<<" "<<i<<endl;
        cout<<"2 "<<dep+1<<endl;
        }
    /*

    int dep = min(n,m);
    int las = max(n,m);

    cout<<dep+1<<endl;

    REP(i,1,dep+1)
    cout<<i<<" "<<i<<endl;
    if(las==n)
    cout<<las<<" 0"<<endl;
    else cout<<"0 "<<las<<endl;
    */

    return 0;
}


#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef vector<ll> vin;
typedef vector<string> vs;
typedef vector<vector<ll> > vvin;

#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define inf 1000000000
#define mp make_pair
#define sz size()
#define all(vec) (vec).begin(),(vec).end()

/*
bool compare(const char &a, const char &b)
{
    return a<b;
}

ll fastexp(ll base, ll exp)
{
    if(exp==0) return 1;
    if(exp==1) return base;

    ll ans = fastexp(base, exp/2);

    return ans*ans*fastexp(base, exp%2);
}

ll gcd(ll a, ll b)
{
    if(a==0) return b;
    if(b==0) return a;

    if(a>b) return gcd(a%b, b);
    else return gcd(a, b%a);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a,b);
}
*/

int N;

int ans(int n)
{
    if(n==1)
    return 1;

    return (N-n+1)*(n-1)+1+ans(n-1);
}

int main()
{
    int n, m, dep;

    cin>>n>>m;

    dep = min(n, m);

        cout<<dep+1<<endl;

        cout<<"1 0\n0 1\n";
        REP(i,2,dep+1)
        cout<<i<<" "<<i<<endl;
    /*

    int dep = min(n,m);
    int las = max(n,m);

    cout<<dep+1<<endl;

    REP(i,1,dep+1)
    cout<<i<<" "<<i<<endl;
    if(las==n)
    cout<<las<<" 0"<<endl;
    else cout<<"0 "<<las<<endl;
    */

    return 0;
}


#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef vector<ll> vin;
typedef vector<string> vs;
typedef vector<vector<ll> > vvin;

#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define inf 1000000000
#define mp make_pair
#define sz size()
#define all(vec) (vec).begin(),(vec).end()

int main()
{
    int n, m;
    cin>>n>>m;
    n = min(n,m);
    cout<<n+1<<endl;
    rep(i,n+1)
    cout<<i<<" "<<n-i<<endl;
    return 0;
}


#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef vector<ll> vin;
typedef vector<string> vs;
typedef vector<vector<ll> > vvin;

#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define inf 1000000000
#define mp make_pair
#define sz size()
#define all(vec) (vec).begin(),(vec).end()

/*
bool compare(const char &a, const char &b)
{
    return a<b;
}

ll fastexp(ll base, ll exp)
{
    if(exp==0) return 1;
    if(exp==1) return base;

    ll ans = fastexp(base, exp/2);

    return ans*ans*fastexp(base, exp%2);
}

ll gcd(ll a, ll b)
{
    if(a==0) return b;
    if(b==0) return a;

    if(a>b) return gcd(a%b, b);
    else return gcd(a, b%a);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a,b);
}
*/

int N;

int ans(int n)
{
    if(n==1)
    return 1;

    return (N-n+1)*(n-1)+1+ans(n-1);
}

int main()
{
    int n, m;

    cin>>n>>m;

    int dep = min(n,m);

    cout<<dep+1<<endl;

    rep(i,dep+1)
    cout<<i<<" "<<i<<endl;

    return 0;
}


#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef vector<ll> vin;
typedef vector<string> vs;
typedef vector<vector<ll> > vvin;

#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define inf 1000000000
#define mp make_pair
#define sz size()
#define all(vec) (vec).begin(),(vec).end()

/*
bool compare(const char &a, const char &b)
{
    return a<b;
}

ll fastexp(ll base, ll exp)
{
    if(exp==0) return 1;
    if(exp==1) return base;

    ll ans = fastexp(base, exp/2);

    return ans*ans*fastexp(base, exp%2);
}

ll gcd(ll a, ll b)
{
    if(a==0) return b;
    if(b==0) return a;

    if(a>b) return gcd(a%b, b);
    else return gcd(a, b%a);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a,b);
}
*/

int N;

int ans(int n)
{
    if(n==1)
    return 1;

    return (N-n+1)*(n-1)+1+ans(n-1);
}

int main()
{
    int n, m, dep;

    cin>>n>>m;

    dep = min(n, m);

        cout<<dep+1<<endl;

        if(dep==m) {
        rep(i,dep)
        cout<<i<<" "<<i+1<<endl;
        cout<<dep<<" 0\n";
        }
        else {
        rep(i,dep)
        cout<<i+1<<" "<<i<<endl;
        cout<<"0 "<<dep<<endl;
        }
    /*

    int dep = min(n,m);
    int las = max(n,m);

    cout<<dep+1<<endl;

    REP(i,1,dep+1)
    cout<<i<<" "<<i<<endl;
    if(las==n)
    cout<<las<<" 0"<<endl;
    else cout<<"0 "<<las<<endl;
    */

    return 0;
}


#include <bits/stdc++.h>

#define max(a,b) a>=b?a:b
#define min(a,b) a<=b?a:b

using namespace std;

long int n , m;

int main()
{
    long int i , j , a , b , c;
    scanf("%ld %ld" , &n , &m);
    a = min(n,m);
    a++;
    printf("%ld\n" , a);
    for(i = 1; i <= a; i++) {
        if(a%2 == 0) {
            printf("%ld %ld\n" , (i-1) , i%a);
            printf("%ld %ld\n" , i%a , i-1);
            i++;
        } else if(a%2 == 1){
            if(i < a) {
                printf("%ld %ld\n" , i-1 , i%a);
                    printf("%ld %ld\n" , i%a , i-1);
                    i++;
            } else if(i == a) {
                    printf("%ld %ld\n" , i-1 , i-1);
                }
        }
    }
    return 0;
}


#include <bits/stdc++.h>

#define max(a,b) a>=b?a:b
#define min(a,b) a<=b?a:b

using namespace std;

long int n , m;

int main()
{
    long int i , j , a , b , c;
    scanf("%ld %ld" , &n , &m);
    a = min(n,m);
    a++;
    printf("%ld\n" , a);
    for(i = 0; i < a; i++) {
        printf("%ld %ld\n" , i , (i+1)%a);
    }
    return 0;
}