#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}
using Graph = vector<vector<long long>>;
int main() {
  long long N, M;
  cin >> N >> M;
  string S = "1";
  for (long long i = (long long)0; i < (long long)N - 1; i++) S += '0';
  bool flag = 0;
  bool done = 0;
  for (long long i = (long long)0; i < (long long)M; i++) {
    long long s, c;
    cin >> s >> c;
    s--;
    if (s >= N) {
      flag = 1;
      continue;
    }
    if (s == 0) {
      if (c == 0) {
        flag = 1;
        continue;
      }
      if (S[s] == (char)(c + '0') || S[s] == '1') {
        if (done) {
          if (c != 1) {
            flag = 1;
          }
        }
        S[s] = (char)(c + '0');
      } else {
        flag = 1;
      }
    } else {
      if (S[s] != '0' && S[s] != (char)(c + '0')) {
        flag = 1;
        continue;
      }
      S[s] = (char)(c + '0');
    }
    if (s == 1 && c == 1) done = 1;
  }
  if (N == 1 && M == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (flag || S[0] == '0') {
    cout << -1 << endl;
  } else {
    cout << S << endl;
  }
}
