#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> ans(n, -1);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (ans[s] != -1 && ans[s] != c) {
      cout << "-1\n";
      return 0;
    }
    ans[s] = c;
  }
  if (n > 1 && ans[0] == 0) {
    cout << "-1\n";
    return 0;
  }
  cout << (ans[0] == -1 ? 1 : ans[0]);
  for (int i = 1; i < n; i++) cout << (ans[i] == -1 ? 0 : ans[i]);
  return 0;
}
