#include <bits/stdc++.h>
using namespace std;
const int INTINF = int(1e9) + 1;
const long long LLINF = long long(1e18) + 1;
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
void solve() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int> > cond;
  for (int i = 0, i_len = (M); i < i_len; ++i) {
    int s, c;
    cin >> s >> c;
    cond.push_back(make_pair(s, c));
  }
  int r = 1;
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    r *= 10;
  }
  for (int i = (r / 10); i < (r); ++i) {
    bool isok = true;
    string s = toString(i);
    for (auto c : cond) {
      if (s[c.first - 1] - '0' != c.second) isok = false;
    }
    if (isok) {
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(10);
  solve();
  return 0;
}
