#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int mod = 1000000007;
P ar[4] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
__attribute__((constructor)) void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main() {
  int n, m;
  cin >> n >> m;
  int ans[n];
  for (int i = 0; n > i; i++) {
    ans[i] = -1;
  }
  for (int i = 0; m > i; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    if (!(ans[a] == -1 || ans[a] == b)) {
      cout << -1 << endl;
      return 0;
    }
    ans[a] = b;
  }
  if (ans[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; n > i; i++) {
    if (!i) {
      cout << (ans[i] != -1 ? ans[i] : 1);
    } else {
      cout << (ans[i] != -1 ? ans[i] : 0);
    }
  }
  cout << endl;
}
