#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> ans(n + 1, -1);
  while (m--) {
    int pos, d;
    cin >> pos >> d;
    if (ans[pos] == -1)
      ans[pos] = d;
    else if (ans[pos] != d) {
      cout << -1;
      exit(0);
    }
  }
  if (ans[1] == 0) {
    if (n == 1) {
      cout << 0;
      exit(0);
    } else {
      cout << -1;
      exit(0);
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (ans[i] == -1) {
      if (i == 1)
        cout << 1;
      else
        cout << 0;
    } else
      cout << ans[i];
  }
}
