#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  bool flag = true;
  vector<int> ans(n, -1);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      flag = false;
    } else if (ans[s] != -1 && ans[s] != c) {
      flag = false;
    }
    ans[s] = c;
  }
  if (!flag) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] == -1 && i == 0)
      ans[i] = 1;
    else if (ans[i] == -1)
      ans[i] = 0;
  }
  for (int i = 0; i < n; i++) cout << ans[i];
  cout << endl;
}
