#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n, m, i;
  cin >> n >> m;
  vector<long long> v(n + 1);
  for (i = 1; i <= n; i++) {
    v[i] = -1;
  }
  long long x, y;
  while (m--) {
    cin >> x >> y;
    if (v[x] == -1) {
      v[x] = y;
    } else {
      if (v[x] == y) {
        continue;
      } else {
        cout << "-1" << endl;
        return 0;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (i == 1) {
      if (v[i] == -1) {
        v[i] = 1;
      } else if (v[i] == 0) {
        cout << "-1" << endl;
        return 0;
      }
    } else {
      if (v[i] == -1) {
        v[i] = 0;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    cout << v[i];
  }
  cout << endl;
  return 0;
}
