#include <bits/stdc++.h>
using namespace std;
long long inf = pow(10, 18);
long long modulo = pow(10, 9) + 7;
double eps = 1e-6;
ifstream in;
ofstream out;
void deal() {
  long long n, m;
  cin >> n >> m;
  string a;
  for (int i = 0; i < n; i++) {
    a += "?";
  }
  for (int i = 0; i < m; i++) {
    long long idx;
    char vl;
    cin >> idx >> vl;
    if (idx == 1 && vl == '0') {
      cout << -1;
      return;
    }
    --idx;
    if (a[idx] == '?') {
      a[idx] = vl;
    }
    if (a[idx] != vl) {
      cout << -1;
      return;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == '?') {
      a[i] = '0';
    }
  }
  if (a[0] == '0') {
    a[0] = '1';
  }
  cout << a;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  deal();
}
