#include <bits/stdc++.h>
using namespace std;
using P = pair<long long, long long>;
const long long mod = 1e9 + 7;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}
template <class T>
inline void chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
}
template <class T>
inline void chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N = in(), M = in();
  vector<int> A(N, 11);
  bool ok = 1;
  for (long long(i) = 0; (i) < (M); (i)++) {
    int dig = in() - 1, num = in();
    if (dig == 0 && num == 0) {
      ok = 0;
    } else if (A[dig] == 11) {
      A[dig] = num;
      cout << A[dig] << dig << "\n";
    } else if (A[dig] != num) {
      ok = 0;
    }
  }
  if (A.size() == 1 && A[0] == 11) A[0] = 0;
  for (long long(i) = 0; (i) < (N); (i)++) {
    if (i == 0) {
      if (A[i] == 11) A[i] = 1;
    } else {
      if (A[i] == 11) A[i] = 0;
    }
  }
  if (ok) {
    for (long long(i) = 0; (i) < (N); (i)++) cout << A[i];
    cout << "\n";
  } else {
    cout << -1 << "\n";
  }
}
