#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const int not0 = 1;
const int INF = 2000000001;
const long long int INFll = 2e18;
const double Micro = 1e-5;
int UnUsedVariable() {
  if (INF || Micro || MOD || INFll || MOD2 || not0) {
    ;
  }
  return 0;
}
inline int isEven(int x) { return x % 2 == 0; }
inline int isOdd(int x) { return x % 2 == 1; }
inline long long int samepair(long long int x) { return x * (x - 1) / 2; }
inline long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
inline long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
long long int dx[4] = {1, 0, -1, 0};
long long int dy[4] = {0, 1, 0, -1};
long long int probNow() {
  long long int ans;
  ans = 0;
  long long int alldigit, bind;
  cin >> alldigit >> bind;
  long long int ansd[alldigit + 1];
  for (long long int i = (1); i <= (alldigit); i++) {
    ansd[i] = -1;
  }
  long long int dig, num;
  for (long long int i = (0); i < (bind); i++) {
    cin >> dig >> num;
    if (dig == 1 and num == 0) {
      {
        cout << (-1) << endl;
        return 0;
      }
    } else if (ansd[dig] == -1) {
      ansd[dig] = num;
    } else if (ansd[dig] != num) {
      {
        cout << (-1) << endl;
        return 0;
      }
    }
  }
  for (long long int i = (1); i <= (alldigit); i++) {
    if (ansd[i] == -1) {
      if (i == 1)
        ansd[i] = 1;
      else
        ansd[i] = 0;
    }
  }
  for (long long int i = (1); i <= (alldigit); i++) {
    cout << ansd[i];
  }
  cout << "\n";
  ;
  return 0;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  probNow();
  return 0;
}
