#include <bits/stdc++.h>
using namespace std;
int N, M;
int s, c;
int suji[4];
bool ans;
void solve() {
  if (ans) {
    for (int i = 0; i < (int)(N); i++) {
      if (suji[i] == -1) {
        if (i == 0)
          cout << 1;
        else
          cout << 0;
      } else {
        cout << suji[i];
      }
    }
    cout << endl;
  } else
    cout << (-1) << endl;
  return;
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < (int)(N); i++) suji[i] = -1;
  ans = true;
  for (int i = 0; i < (int)(M); i++) {
    cin >> s >> c;
    if (suji[s - 1] == -1)
      suji[s - 1] = c;
    else if (suji[s - 1] != c)
      ans = false;
  }
  if (suji[0] == 0) ans = false;
  solve();
  return 0;
}
