#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n, -1);
  bool game = true;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    if (v[x] != -1 && v[x] != y) {
      game = false;
    } else if (v[x] == -1) {
      if (x == 0 && y == 0) {
        game = false;
      }
      v[x] = y;
    }
  }
  if (game) {
    for (int i = 0; i < n; i++) {
      if (v[i] == -1 && i != 0)
        v[i] = 0;
      else if (v[i] == -1 && i == 0)
        v[i] = 1;
    }
    for (int i = 0; i < n; i++) cout << v[i];
    cout << endl;
  } else
    cout << -1 << endl;
}
