#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m, w;
  int num;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) a[i] = 100;
  for (int i = 0; i < m; i++) {
    cin >> w >> num;
    if (w == 1 && num == 0) continue;
    a[w - 1] = min(a[w - 1], num);
  }
  if (a[0] == 100)
    if (n != 1) {
      cout << -1 << endl;
      return 0;
    } else {
      cout << 0 << endl;
      return 0;
    }
  for (auto c : a) {
    if (c == 100) c = 0;
    cout << c;
  }
  cout << endl;
}
