#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
inline string toString(const T &a) {
  ostringstream oss;
  oss << a;
  return oss.str();
};
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = (int)(0); i < (int)(m); i++) cin >> s[i] >> c[i];
  int ans = 1000;
  if (m == 0) {
    if (n > 1)
      cout << pow(10, n - 1) << endl;
    else
      cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i <= pow(10, n) - 1; i++) {
    string num = toString(i);
    bool check = true;
    for (int j = (int)(0); j < (int)(m); j++) {
      if (num[s[j] - 1] - '0' != c[j]) {
        check = false;
        break;
      }
    }
    if (check) {
      ans = i;
      break;
    }
  }
  if (ans == 1000)
    cout << -1 << endl;
  else
    cout << ans << endl;
}
