#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
long long MOD = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      a[i] = 0;
    } else if (i == n - 1) {
      a[i] = 1;
    } else {
      a[i] = 0;
    }
  }
  int l[n];
  for (int i = 0; i < n; i++) {
    l[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x = n - x;
    if (l[x] == 1) {
      if (a[x] != y) {
        cout << -1 << endl;
        return 0;
      }
    } else {
      l[x] = 1;
      a[x] = y;
    }
  }
  if (a[n - 1] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = n - 1; i >= 0; i--) {
    cout << a[i];
  }
  cout << endl;
  return 0;
}
