#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> num(n, -1);
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    --s;
    if (num[s] != -1 && num[s] != c || s == 0 && c == 0 && n > 1) {
      cout << -1 << endl;
      return 0;
    }
    num[s] = c;
  }
  for (int i = 0; i < num.size(); ++i)
    if (num[i] == -1) num[i] = (i == 0 ? 1 : 0);
  for (int i = 0; i < n; ++i) cout << num[i];
  cout << endl;
}
