#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, pair<T1, T2> P) {
  return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream& operator<<(ostream& s, vector<T> P) {
  for (int i = 0; i < P.size(); ++i) {
    if (i > 0) {
      s << " ";
    }
    s << P[i];
  }
  return s;
}
template <class T>
ostream& operator<<(ostream& s, vector<vector<T> > P) {
  for (int i = 0; i < P.size(); ++i) {
    s << endl << P[i];
  }
  return s << endl;
}
template <class T>
ostream& operator<<(ostream& s, set<T> P) {
  for (auto it : P) {
    s << "<" << it << "> ";
  }
  return s << endl;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, map<T1, T2> P) {
  for (auto it : P) {
    s << "<" << it.first << "->" << it.second << "> ";
  }
  return s << endl;
}
int N, M;
vector<int> s, c;
bool ok(string str) {
  if (str.size() != N) return false;
  for (int i = 0; i < M; ++i) {
    if (str[s[i]] != (char)(c[i] + '0')) return false;
  }
  return true;
}
string solve() {
  for (int i = 1; i <= 999; ++i) {
    stringstream iss;
    iss << i;
    string str = iss.str();
    if (ok(str)) return str;
  }
  return "-1";
}
int main() {
  while (cin >> N >> M) {
    s.resize(M);
    c.resize(M);
    for (int i = 0; i < M; ++i) cin >> s[i] >> c[i], --s[i];
    cout << solve() << endl;
  }
}
