#include <bits/stdc++.h>
using namespace std;
const long long INF64 = 1e18;
clock_t time_p = clock();
void time() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
void doc() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  fast();
  long long n, i, m;
  cin >> n >> m;
  string z = "", s = "";
  for (i = 0; i < n; i++) {
    s += '@';
    z += '0';
  }
  while (m--) {
    long long pos;
    char x;
    cin >> pos >> x;
    pos--;
    if (s[pos] != '@') {
      if (s[pos] == x) continue;
      cout << "-1";
      exit(0);
    }
    s[pos] = x;
  }
  bool flag = false;
  i = 0;
  while (i < n) {
    if (s[i] == '@') {
      s[i] = '1';
      flag = true;
    } else
      break;
    i++;
  }
  i = 0;
  while (i < n) {
    if (s[i] == '@') s[i] = '0';
    i++;
  }
  if (s == "0") {
    cout << s;
    exit(0);
  }
  if (s == z) {
    cout << "-1";
    exit(0);
  }
  cout << s;
}
