#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  string ans(n, 'x');
  long long s[m], c[m];
  for (long long i = (0); i < (m); i++) {
    cin >> s[i] >> c[i];
    s[i]--;
    if (s[i] == 0 && c[i] == 0) {
      ans = "-1";
      break;
    }
    if (ans[s[i]] == 'x') {
      ans[s[i]] = '0' + c[i];
    } else {
      if (ans[s[i]] != '0' + c[i]) {
        ans = "-1";
        break;
      }
    }
  }
  for (long long i = (0); i < (n); i++) {
    if (ans[i] == 'x') {
      ans[i] = (i == 0 && n != 1) ? '1' : '0';
    }
  }
  cout << (ans) << endl;
  return 0;
}
