#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long to, cost;
};
long long ceil2(long long a, long long b) {
  if (a % b) {
    return a / b + 1;
  } else {
    return a / b;
  }
}
long long n, m;
long long s[111111], c[111111];
long long num[111111];
signed main() {
  for (long long i = 0; i < 111111; i++) num[i] = -1;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) cin >> s[i] >> c[i];
  for (long long i = 0; i < m; i++) {
    if (num[s[i]] == -1) {
      num[s[i]] = c[i];
    } else {
      if (num[s[i]] != c[i]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (num[1] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (long long i = 0; i < n; i++) {
    if (num[i + 1] == -1)
      cout << 1;
    else
      cout << num[i + 1];
  }
  cout << endl;
}
