#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ans(N, -1);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    if (ans[a - 1] == -1 || ans[a - 1] == b)
      ans[a - 1] = b;
    else {
      cout << "-1" << endl;
      return 0;
    }
  }
  if (ans[0] == 0) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 0; i < N; i++) {
    if (ans[i] != -1)
      cout << ans[i];
    else if (i == 0)
      cout << "1";
    else
      cout << "0";
  }
  cout << endl;
}
