#include <bits/stdc++.h>
using namespace std;
vector<int> v2;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v1(11, -1);
  int r = 0;
  int br = 0;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (v1[x] == -1 || v1[x] == y) {
      v1[x] = y;
    } else {
      br = 1;
    }
  }
  if (br == 1) {
    cout << "-1";
    return 0;
  }
  if (n == 1) {
    cout << v1[1];
    return 0;
  }
  if (v1[1] == 0) {
    br = 1;
  }
  if (br == 1) {
    cout << "-1";
    return 0;
  }
  if (v1[1] == -1) {
    v1[1] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (v1[i] == -1) {
      v1[i] = 0;
    }
    cout << v1[i];
  }
}
