#include <bits/stdc++.h>
using namespace std;
void x() {
  int n, m;
  cin >> n >> m;
  if (m == 0) cout << -1;
  return;
  vector<int> number(n, 0);
  int ans;
  vector<vector<int>> vec(m, vector<int>(2));
  for (int i = 0; i < m; i++) cin >> vec.at(i).at(0) >> vec.at(i).at(1);
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < i; j++) {
      if ((vec.at(i).at(0) == vec.at(j).at(0) &&
           vec.at(i).at(1) != vec.at(j).at(1)) ||
          (vec.at(i).at(0) == 0 && vec.at(i).at(1) == 0)) {
        cout << -1;
        return;
      }
    }
  }
  for (int i = 0; i < n; i++) number.at(vec.at(i).at(0) - 1) = vec.at(i).at(1);
  if (number.at(0) == 0) number.at(0) == 1;
  for (int i = 0; i < n; i++) {
    cout << number[i];
  }
  return;
}
int main() { x(); }
