#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long dx[] = {-1, 0, 1, 0};
long long dy[] = {0, -1, 0, 1};
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> v(n, -1);
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    x--;
    if (v[x] != -1) {
      if (v[x] != y) {
        cout << -1;
        return 0;
      }
    }
    v[x] = y;
  }
  if (v[0] == -1) v[0] = 1;
  if (v[0] == 0) {
    cout << -1;
    return 0;
  }
  for (long long i = 0; i < n; i++) {
    if (v[i] == -1) v[i] = 0;
    cout << v[i];
  }
}
