#include <bits/stdc++.h>
using namespace std;
int a[200005];
int b[200005];
map<int, long long> mp;
double i, j, k, l;
int i1, k1, j2;
int main() {
  int a, b;
  cin >> b >> a;
  int flag = 1;
  int q[100];
  memset(q, -1, sizeof(q));
  while (a--) {
    int n, m;
    cin >> n >> m;
    if (q[n] == -1 || q[n] == m) {
      q[n] = m;
    } else
      flag = 0;
    if (n == 1 && m == 0) flag = 0;
  }
  if (flag) {
    for (int i = 1; i <= b; i++) {
      if (i == 1 && q[1] == -1) q[1] = 1;
      if (q[i] == -1) q[i] = 0;
      cout << q[i];
    }
  } else
    cout << "-1";
}
