#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  map<int, int> ans;
  for (int i = 1; i <= M; i++) {
    int a, b;
    cin >> a >> b;
    if ((ans.count(a) == true) & (ans[a] != b)) {
      cout << "-1" << endl;
      return 0;
    } else if ((a == 1) & (b == 0)) {
      cout << "-1" << endl;
      return 0;
    } else {
      ans[a] = b;
    }
  }
  for (int i = 1; i <= M; i++) {
    if (ans.count(i)) {
      if ((i == 0) & (ans[i] != 0)) {
        ans[i] = 1;
      } else
        continue;
    } else {
      ans[i] = 0;
    }
  }
  for (int i = 1; i <= M; i++) {
    cout << ans[i];
  }
  cout << endl;
}
