#include <bits/stdc++.h>
using namespace std;
int ans[4] = {-1, -1, -1, -1};
int main() {
  int n, m, a, b;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--;
    if (ans[a] != -1 && ans[a] != b) {
      cout << "-1\n";
      return 0;
    }
    ans[a] = b;
  }
  bool zero = false;
  for (int i = 0; i < n; i++) {
    if (ans[i] == 0 && !zero) {
      cout << "-1\n";
      return 0;
    } else {
      if (ans[i] == -1 && !zero) ans[i] = 1;
      zero = true;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << max(ans[i], 0);
  }
  cout << '\n';
}
