#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  if (m == 0) {
    ans = pow(10, n - 1);
    cout << ans;
    return 0;
  }
  vector<pair<int, int>> a(m);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    a[i] = make_pair(s, c);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < m; i++) cout << a[i].first << " " << a[i].second << " ";
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      if (i != j && a[i].first == a[j].first && a[i].second != a[j].second) {
        cout << -1;
        return 0;
      }
    }
  }
  if (n == 3 && a[0].first != 1) ans = 100;
  if (n == 2 && a[0].first != 1) ans = 10;
  for (int i = 1; i < m; i++) {
    if (a[i - 1].first != a[i].first) {
      int temp = pow(10, n - a[i - 1].first);
      ans += a[i - 1].second * temp;
    }
    if (i == m - 1) {
      int temp = pow(10, n - a[i].first);
      ans += a[i].second * temp;
    }
  }
  int c = log10(ans) + 1;
  if (n != 1 && c != n) {
    cout << -1;
    return 0;
  }
  cout << ans;
}
