#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vec(n, 0);
  vector<int> count(n, 0);
  bool flag = true;
  if (m > 0) {
    for (int i = 0; i < m; i++) {
      int a, b;
      cin >> a >> b;
      if (count[a - 1] == 0) {
        vec[a - 1] = b;
        count[a - 1] = 1;
      } else {
        if (vec[a - 1] != b) flag = false;
      }
    }
    if (flag == true && vec[0] != 0) {
      for (int i : vec) {
        cout << i;
      }
      cout << endl;
    } else
      cout << -1 << endl;
  } else {
    if (n == 1)
      cout << 0 << endl;
    else if (n == 2)
      cout << 10 << endl;
    else
      cout << 100 << endl;
  }
}
