#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592653589;
const int INF = 1000000007;
const long long LMAX = 1000000000000001;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  long long c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> d(n, -1);
  bool f = 0;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (d[s] == -1)
      d[s] = c;
    else if (d[s] != c)
      f = 1;
  }
  if (f || d[0] == 0)
    cout << -1 << endl;
  else {
    if (d[0] == -1) d[0] = 1;
    for (int i = 0; i < n; i++) {
      if (d[i] == -1) d[i] = 0;
      cout << d[i];
    }
    cout << endl;
  }
  return 0;
}
