#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long mod2 = 998244353;
const int inf = 1e9 + 10;
const long long INF = 1e18;
const long double EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = 0; i < (m); ++i) cin >> s[i] >> c[i];
  vector<int> ans(n, -1);
  for (int i = 0; i < (m); ++i) {
    if (s[i] > n) {
      cout << -1 << endl;
      return 0;
    }
    if (ans[s[i] - 1] != -1 && ans[s[i] - 1] != c[i]) {
      cout << -1 << endl;
      return 0;
    }
    if (n > 1 && s[i] == 1 && c[i] == 0) {
      cout << -1 << endl;
      return 0;
    }
    ans[s[i] - 1] = c[i];
  }
  if (ans[0] == -1 && n > 1)
    ans[0] = 1;
  else
    ans[0] = 0;
  for (int i = (1); i < (n); ++i) {
    if (ans[i] == -1) ans[i] = 0;
  }
  for (int i = 0; i < (n); ++i) cout << ans[i];
  cout << endl;
  return 0;
}
