#include <bits/stdc++.h>
using namespace std;
using p = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < (m); i++) {
    int s, c;
    cin >> s >> c;
    a[s - 1] = c;
  }
  int ans = 0;
  if (a[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int j = 0; j < (n); j++) {
    ans += a[j] * pow(10, n - j - 1);
  }
  cout << ans << endl;
  return 0;
}
