#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pil = pair<int, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  for (int j = 0; j < (v.size()); ++j) i >> v[j];
  return i;
}
template <typename T>
string join(const vector<T>& v) {
  stringstream s;
  for (int i = 0; i < (v.size()); ++i) s << ' ' << v[i];
  return s.str().substr(1);
}
template <typename T>
inline ostream& operator<<(ostream& o, const vector<T>& v) {
  if (v.size()) o << join(v);
  return o;
}
template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}
template <typename T1, typename T2>
inline ostream& operator<<(ostream& o, const pair<T1, T2>& v) {
  return o << v.first << "," << v.second;
}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
template <class T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  } else
    return 0;
}
template <class T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  } else
    return 0;
}
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
const int mod = 1000000007;
void Main() {
  int n;
  int m;
  cin >> n >> m;
  vi s(m);
  vi c(m);
  for (int i = 0; i < (m); ++i) cin >> s[i] >> c[i];
  vi ans(n, -1);
  for (int i = 0; i < (m); ++i) {
    if (s[i] > n) {
      cout << -1 << endl;
      return;
    }
    if (ans[s[i] - 1] == -1) {
      ans[s[i] - 1] = c[i];
    } else {
      if (ans[s[i] - 1] != c[i]) {
        cout << -1 << endl;
        return;
      }
    }
  }
  for (int i = 0; i < (n); ++i) {
    if (i == 0 and ans[i] == -1) {
      ans[i] = 1;
    } else {
      if (ans[i] == -1) {
        ans[i] = 0;
      }
    }
  }
  if (ans[0] == 0) {
    cout << -1 << endl;
    return;
  }
  for (int i = 0; i < (n); ++i) {
    cout << ans[i];
  }
  cout << endl;
}
signed main(int argc, char** argv) {
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  ;
  ifstream iofi;
  if (argc > 1) {
    iofi.open(argv[1]);
    std::cin.rdbuf(iofi.rdbuf());
  };
  int loop = 1;
  if (argc > 2) loop = stoi(argv[2]);
  for (int i = 0; i < (loop); ++i) Main();
}
