#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  bool flag = true;
  cin >> N >> M;
  vector<int> S(N);
  int s, c;
  for (int i = 0; i < (N); i++) S[i] = 10;
  for (int i = 0; i < (M); i++) {
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      cout << "-1" << endl;
      flag = false;
      break;
    }
    if (S[s] == 10 || S[s] == c)
      S[s] = c;
    else {
      cout << "-1" << endl;
      flag = false;
      break;
    }
  }
  if (flag) {
    for (int i = 0; i < (N); i++) {
      if (S[i] == 10) {
        if (i == 0)
          S[i] = 1;
        else
          S[i] = 0;
      }
      cout << S[i];
    }
    cout << endl;
  }
}
