#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> s(n + 1, 0);
  bool bl = true;
  for (int i = 1; i <= m; ++i) {
    int p, t;
    cin >> p >> t;
    s[p] = t;
  }
  if (n > 1)
    for (int i = 1; i <= n; ++i) {
      if (s[i] == 0) {
        bl = false;
        break;
      } else {
        break;
      }
    }
  if (bl)
    for (int i = 1; i <= n; ++i) cout << s[i];
  else
    cout << -1;
  return 0;
}
