#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> num(n, -1);
  int s, c;
  int f = 0;
  for (int i = 0; i < m; ++i) {
    cin >> s >> c;
    if (s == 1 && c == 0) {
      f = 1;
    }
    if (num[s - 1] == -1) {
      num[s - 1] = c;
    } else {
      if (num[s - 1] != c) {
        f = 1;
      } else {
        continue;
      }
    }
  }
  if (f == 1) {
    cout << -1 << endl;
  } else {
    for (int i = 0; i < n; ++i) {
      if (i == 0) {
        if (num[i] == -1)
          cout << 1;
        else
          cout << num[i];
      } else {
        if (num[i] == -1)
          cout << 0;
        else
          cout << num[i];
      }
    }
    cout << endl;
  }
}
