#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const int IINF = (1 << 30);
const ll LLINF = 1LL << 60;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<char> hoge(n);
  int s;
  char c;
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (hoge[s - 1] != 0) {
      if (hoge[s - 1] != c) {
        cout << "-1" << endl;
        return 0;
      }
    }
    hoge[s - 1] = c;
  }
  if (m == 0) {
    cout << "-1" << endl;
    return 0;
  }
  if (n == 1) {
    cout << hoge[0] << endl;
    return 0;
  } else {
    if (hoge[0] == '0') {
      cout << "-1" << endl;
      return 0;
    } else {
      for (int i = 0; i < hoge.size(); i++) {
        if (hoge[i] == 0) {
          if (i == 0) {
            hoge[i] = '1';
          } else {
            hoge[i] = '0';
          }
        }
      }
    }
  }
  string S;
  for (int i = 0; i < hoge.size(); i++) {
    S += hoge[i];
  }
  cout << S << endl;
}
