#include <bits/stdc++.h>
using namespace std;
struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
const long long INF = numeric_limits<long long>::max();
int main() {
  int n, m;
  cin >> n >> m;
  int s, c;
  bool flag = true;
  vector<int> v(4, -1);
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (c == 0 && s == 1 && n != 1) {
      flag = false;
    } else {
      if (v[s] >= 0 && v[s] != c) {
        flag = false;
      }
      v[s] = c;
    }
  }
  if (flag) {
    for (int i = 1; i <= n; i++) {
      if (v[i] < 0) {
        if (i == 1)
          cout << "1";
        else
          cout << "0";
      } else {
        cout << v[i];
      }
    }
    cout << endl;
  } else
    cout << "-1" << endl;
  return 0;
}
