#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ans(N, -1);
  for (int i = (0), i_end_ = (M); i < i_end_; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (ans[s] == -1) {
      ans[s] = c;
    } else if (ans[s] != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = (0), i_end_ = (N); i < i_end_; i++) {
    if (ans[i] == -1) {
      if (i == 0 && N != 1) {
        ans[i] = 1;
      } else {
        ans[i] = 0;
      }
    }
  }
  for (int i = (0), i_end_ = (N); i < i_end_; i++) cout << ans[i];
  cout << endl;
}
