#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:667772160")
using namespace std;
struct __isoff {
  __isoff() {
    if (0) freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
    srand('C' + 'T' + 'A' + 'C' + 'Y' + 'M' + 'B' + 'A');
  }
  ~__isoff() {}
} __osafwf;
const unsigned long long p1 = 31;
const unsigned long long p2 = 29;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int infi = 1e9 + 7;
const long long inf = 1e18 + 7;
const long long dd = 7e5 + 7;
const long long mod = 1e9 + 7;
const long long mod2 = 1e6 + 3;
pair<int, int> TT;
long long vec(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
  a.first -= b.first;
  a.second -= b.second;
  c.first -= b.first;
  c.second -= b.second;
  return 1ll * a.first * c.second - 1ll * a.second * c.first;
}
long long dis(pair<int, int> a, pair<int, int> b) {
  a.first -= b.first;
  a.second -= b.second;
  return 1ll * a.first * a.first + 1ll * a.second * a.second;
}
bool cmp(pair<int, int> a, pair<int, int> b) {
  int t = vec(a, TT, b);
  if (t == 0) {
    return dis(a, TT) < dis(b, TT);
  }
  return t < 0;
}
vector<pair<int, int> > Con(vector<pair<int, int> > G) {
  int m = G.size();
  for (long long i = 0; i < (long long)m; i++) {
    if (G[i] < G[0]) {
      swap(G[i], G[0]);
    }
  }
  TT = G[0];
  sort(G.begin() + 1, G.end(), cmp);
  vector<pair<int, int> > E;
  for (long long i = 0; i < (long long)m; i++) {
    while (E.size() > 1 && vec(E[E.size() - 2], E[E.size() - 1], G[i]) <= 0) {
      E.pop_back();
    }
    E.push_back(G[i]);
  }
  return E;
}
int main() {
  int n, m;
  while (cin >> n >> m) {
    if (n == 0) return 0;
    map<int, map<int, int> > T;
    vector<pair<int, int> > Z, W;
    for (long long i = 0; i < (long long)m; i++) {
      int x, y;
      cin >> x >> y;
      T[x][y] = 1;
      Z.push_back(make_pair(x, y));
    }
    W = Z;
    Z = Con(Z);
    for (long long i = 0; i < (long long)Z.size(); i++) {
      T[Z[i].first][Z[i].second] = 2;
    }
    vector<pair<int, int> > G;
    for (long long k = 0; k < (long long)m; k++) {
      int i = W[k].first;
      int j = W[k].second;
      if (T[i][j] == 2) {
        if (T[i - 1][j] > 0 && T[i][j - 1] > 0 && T[i + 1][j] == 0 &&
            T[i][j + 1] == 0) {
          G.push_back(make_pair(i, j));
        }
        if (T[i + 1][j] > 0 && T[i][j + 1] > 0 && T[i - 1][j] == 0 &&
            T[i][j - 1] == 0) {
          G.push_back(make_pair(i + 1, j + 1));
        }
        if (T[i + 1][j] > 0 && T[i][j - 1] > 0 && T[i - 1][j] == 0 &&
            T[i][j + 1] == 0) {
          G.push_back(make_pair(i + 1, j));
        }
        if (T[i - 1][j] > 0 && T[i][j + 1] > 0 && T[i + 1][j] == 0 &&
            T[i][j - 1] == 0) {
          G.push_back(make_pair(i, j + 1));
        }
      }
    }
    for (long long i = 0; i < (long long)G.size(); i++) {
      G[i].first -= 1;
      G[i].second -= 1;
    }
    sort(G.begin(), G.end());
    G.resize(unique(G.begin(), G.end()) - G.begin());
    auto E = Con(G);
    cout << E.size() << '\n';
    for (long long i = 0; i < (long long)E.size(); i++) {
      cout << E[i].first << ' ' << E[i].second << '\n';
    }
  }
}
