#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int main() {
  vector<vector<int>> A(3);
  vector<int> B;
  int N, M;
  cin >> N >> M;
  int ans[N];
  for (int i = 0; i < (N); i++) ans[i] = -1;
  for (int i = 0; i < (M); i++) {
    int s;
    int c;
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (ans[s] == -1) {
      ans[s] = c;
    } else if (ans[s] != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < (N); i++) {
    if (ans[i] == -1) {
      if (i == 0) {
        ans[i] = 1;
      } else {
        ans[i] = 0;
      }
    }
  }
  for (int i = 0; i < (N); i++) cout << ans[i];
  cout << endl;
  return 0;
}
