#include <bits/stdc++.h>
using namespace std;
long long mod(long long a) {
  long long c = a % (long long)(1E9 + 7);
  if (c >= 0) return c;
  return c + (long long)(1E9 + 7);
}
long long inf = (long long)1E16;
long long max(long long a, long long b) {
  if (a < b)
    return b;
  else
    return a;
}
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
void Max(long long &pos, long long val) { pos = max(pos, val); }
void Min(long long &pos, long long val) { pos = min(pos, val); }
void Add(long long &pos, long long val) { pos = mod(pos + val); }
long double EPS = 1E-9;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  long long a[n];
  for (long long i = 0; i <= n - 1; i++) a[i] = -1;
  while (m--) {
    long long s, x;
    cin >> s >> x;
    s--;
    if (a[s] == -1) {
      a[s] = x;
    } else {
      if (a[s] != x) {
        cout << -1 << "\n";
        return 0;
      }
    }
  }
  for (long long i = 0; i <= n - 1; i++) {
    if (i == 0) {
      if (a[i] == 0) {
        cout << -1 << "\n";
        return 0;
      }
      if (a[i] == -1) a[i] = 1;
    } else {
      if (a[i] == -1) a[i] = 0;
    }
  }
  for (long long i = 0; i <= n - 1; i++) cout << a[i];
  cout << "\n";
  return 0;
}
