#include <bits/stdc++.h>
const long long way[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double EXP = 1e-8;
const long long MOD = 1e9 + 7;
const long long N = 2e5 + 5;
long long n, m;
long long a[5];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  long long ok = 0;
  while (m--) {
    long long i, x;
    cin >> i >> x;
    if (i == 1) ok = 1;
    if ((a[i] && a[i] != x)) {
      cout << -1 << endl;
      return 0;
    }
    a[i] = x;
  }
  string s;
  for (long long i = 1; i <= n; i++) s.insert(s.end(), a[i] + '0');
  if (s[0] == '0') {
    if (n > 1) s[0] = '1';
    if (n == 1 && !ok) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << s << endl;
  return 0;
}
