#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>
void pPRINT(std::ostream& ost, const T t, const U... u) {
  ost << t << " ";
  pPRINT(ost, u...);
}
template <class... T>
void PRINT(const T... t) {
  pPRINT(std::cout, t...);
}
template <class... T>
void PRINTl(const T... t) {
  pPRINT(std::cout, t...);
  std::cout << "\n";
}
template <class T>
void PRINTa(const T* const t, const ll size) {
  for (int i = 0; i < size; i++) PRINT(t[i]);
  PRINTl();
}
template <class T>
void PRINTal(const T* const t, const ll size) {
  for (int i = 0; i < size; i++) PRINTl(i, ":", t[i]);
}
template <class T>
void DEBUGARR(const T* const t, const ll size) {}
template <class T>
void DEBUGARRL(const T* const t, const ll size) {}
void init() {
  ;
  cin.tie(0);
  ios::sync_with_stdio(false);
}
ll dfs(vector<vector<ll>>& tree, ll parent, ll now, ll depth) {
  ll d = depth;
  for (auto i : tree[now]) {
    if (i == parent) continue;
    d = max(d, dfs(tree, now, i, depth + 1));
  }
  return d;
}
void solve();
int main(int argc, char* argv[]) {
  ;
  init();
  solve();
  return 0;
}
void solve() {
  ;
  ll n, m;
  cin >> n >> m;
  ll s[m], c[m];
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
  }
  for (int i = 0; i < m; i++) {
    s[i]--;
  }
  char ans[n];
  for (int i = 0; i < n; i++) {
    ans[i] = 'n';
  }
  for (int i = 0; i < m; i++) {
    if (ans[s[i]] == 'n' || ans[s[i]] == '0' + c[i]) {
      ans[s[i]] = '0' + c[i];
    } else {
      PRINT(-1);
      return;
    }
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] == 'n') {
      ans[i] = i == 0 ? '1' : '0';
    }
  }
  if (ans[n - 1] == '0' && n != 0)
    PRINT(-1);
  else
    PRINT(ans);
  return;
}
