#include <bits/stdc++.h>
using namespace std;
class Comb {
 private:
  long long *fac, *finv, *inv;

 public:
  Comb() {
    fac = new long long[1000000];
    finv = new long long[1000000];
    inv = new long long[1000000];
    fac[0] = 1;
    for (int i = 1; i < 1000000; i++) {
      fac[i] = i * fac[i - 1];
      fac[i] %= 1000000007;
    }
    inv[1] = 1;
    for (int i = 2; i < 1000000; i++) {
      inv[i] = 1000000007 - inv[1000000007 % i] * (1000000007 / i) % 1000000007;
    }
    finv[0] = 1;
    for (int i = 1; i < 1000000; i++) {
      finv[i] = inv[i] * finv[i - 1];
      finv[i] %= 1000000007;
    }
  }
  long long calc(long long n, long long k) {
    long long c = fac[n];
    c *= finv[k];
    c %= 1000000007;
    c *= finv[n - k];
    c %= 1000000007;
    return c;
  }
};
long long gcd(long long a, long long b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<char> digit(n + 1);
  for (int i = 0; i < n + 1; i++) {
    digit[i] = '.';
  }
  int s;
  char c;
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (digit[s] == '.') {
      digit[s] = c;
      continue;
    }
    if (digit[s] != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (digit[1] == '0' && n != 1) {
    cout << -1 << endl;
    return 0;
  }
  string ans = "";
  for (int i = 1; i < n + 1; i++) {
    if (digit[i] == '.') {
      if (i == 1)
        ans = ans + "1";
      else
        ans = ans + "0";
      continue;
    }
    ans = ans + digit[i];
  }
  cout << ans << endl;
  return 0;
}
