#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > sv;
  for (int i = 0; i < (int)(m); ++i) {
    int s;
    int c;
    cin >> s >> c;
    sv.emplace_back(s, c);
  }
  int ans = -1;
  for (int i = pow(10, n - 1); i <= pow(10, n) - 1; i++) {
    string str = to_string(i);
    bool isOk = true;
    for (auto au : sv) {
      if (str[au.first - 1] != '0' + au.second) {
        isOk = false;
      }
    }
    if (isOk) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}
