#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n, m;
  cin >> n >> m;
  int s, c;
  vector<int> a(n, -1);
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (!(s == 1 && c == 0) && (a[s - 1] == -1 || a[s - 1] == c)) {
      a[s - 1] = c;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; i++)
    i == 0 && a[i] == -1 ? cout << 1 : a[i] != -1 ? cout << a[i] : cout << 0;
  cout << endl;
}
