#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MX = 2e5 + 2;
const long long INF = 1000000000000000000;
const long double PI = 4 * atan((long double)1);
const pair<int, int> dir[4] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int n, m, a, b;
int c[3];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  cin >> n >> m;
  for (int i = 0; i < 3; i++) {
    c[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--;
    if (c[a] != 0 && c[a] != b) {
      cout << -1;
      return 0;
    }
    c[a] = b;
  }
  bool zeroPlaced = false;
  for (int i = 0; i < n; i++) {
    if (c[i] == 0) {
      if (zeroPlaced)
        cout << 0;
      else
        cout << 1;
    } else {
      cout << c[i];
    }
  }
  return 0;
}
