#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;
string alp = "abcdefghijklmnopqrstuvwxyz";
int main() {
  long long n;
  cin >> n;
  long long m;
  cin >> m;
  long long a[n + 1];
  for (long long i = 1; i <= n; i++) a[i] = -1;
  long long s, c;
  for (long long i = 1; i <= m; i++) {
    cin >> s >> c;
    if (a[s] == -1) {
      a[s] = c;
    } else if (a[s] != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (n > 1 && a[1] == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (a[1] == -1) {
    a[1] = 1;
  }
  for (long long i = 1; i <= n; i++) {
    if (a[i] == -1) {
      a[i] = 0;
    }
    cout << a[i];
  }
  cout << endl;
  return 0;
}
