#include <bits/stdc++.h>
using namespace std;
long long n, m, z, x, s, a[5], c[5];
int main() {
  cin >> n;
  cin >> m;
  int ff = 0;
  long long ans = 0;
  if (m == 0) {
    cout << 1;
    for (int i = 2; i <= n; i++) cout << 0;
  }
  for (int i = 1; i <= m; i++) {
    cin >> z >> x;
    if (a[z] == 0 && c[z] == 0) {
      c[z]++;
      a[z] = x;
    } else if (c[z] == 1 && a[z] != x)
      ans = -1;
  }
  if (ans == -1 || a[1] == 0)
    cout << -1 << "\n";
  else
    for (int i = 1; i <= n; i++) cout << a[i];
}
