#include <bits/stdc++.h>
using namespace std;
template <class T>
using V = vector<T>;
template <class S, class T>
using P = pair<S, T>;
using ll = long long;
using ull = unsigned long long;
using vll = V<ll>;
using vvll = V<vll>;
using vvvll = V<vvll>;
using pl = P<ll, ll>;
using vpl = V<pl>;
using vvpl = V<vpl>;
using vs = V<string>;
using qll = queue<ll>;
using qpl = queue<pl>;
using mapll = map<ll, ll>;
using setll = set<ll>;
using pqll = priority_queue<ll>;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
void Input() {}
template <class Var, class... Args>
void Input(Var &var, Args &...args) {
  cin >> var;
  Input(args...);
}
void vInit(ll size) {}
template <class T, class... Args>
void vInit(ll size, V<T> &v, Args &...args) {
  v.resize(size);
  vInit(size, args...);
}
void vInputNum(ll num) {}
template <class T, class... Args>
void vInputNum(ll num, V<T> &v, Args &...args) {
  cin >> v[num];
  vInputNum(num, args...);
}
void vInput(ll size) {}
template <class... Args>
void vInput(ll size, Args &...args) {
  vInit(size, args...);
  for (ll(i) = (0); (i) <= (ll)((ll)(size)-1); (i)++) vInputNum(i, args...);
}
template <class S, class T>
ostream &operator<<(ostream &out, const P<S, T> &p) {
  return out << "[" << p.first << ", " << p.second << "]";
}
template <class T>
ostream &operator<<(ostream &out, V<T> &v) {
  if (v.empty())
    return out << "{}";
  else {
    auto itr = v.begin();
    out << "{" << *itr;
    itr++;
    while (itr != v.end()) {
      out << ", " << *itr;
      itr++;
    }
    out << "}";
    return out;
  }
}
template <class S, class T>
ostream &operator<<(ostream &out, const map<S, T> &m) {
  if (m.empty())
    return out << "<[]>";
  else {
    auto itr = m.begin();
    out << "< [" << (itr->first) << ": " << (itr->second);
    itr++;
    while (itr != m.end()) {
      out << "], [" << (itr->first) << ": " << (itr->second);
      itr++;
    }
    out << "] >";
    return out;
  }
}
template <class T>
ostream &operator<<(ostream &out, const set<T> &s) {
  if (s.empty())
    return out << "<>";
  else {
    auto itr = s.begin();
    out << "<" << *itr;
    itr++;
    while (itr != s.end()) {
      out << ", " << *itr;
      itr++;
    }
    out << ">";
    return out;
  }
}
ll gcd(ll a, ll b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }
  return b ? gcd(b, a % b) : a;
}
ll gcdex(ll a, ll b) { return b ? gcdex(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
struct UFT {
 public:
  ll tsize;
  ll mode;
  vll par;
  vll rank;
  UFT() {}
  UFT(const UFT &uft) {}
  UFT(ll tsizeget, ll modeget = 0) {
    tsize = tsizeget;
    mode = modeget;
    par.assign(tsize, -1);
    if (!mode) rank.resize(tsize, 0);
  }
  ll root(ll x) { return par[x] < 0 ? x : par[x] = root(par[x]); }
  bool isRoot(ll x) { return x == root(x); }
  bool same(ll x, ll y) { return root(x) == root(y); }
  void merge(ll x, ll y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (mode) {
      par[x] += par[y];
      par[y] = x;
    } else {
      if (rank[x] < rank[y]) {
        par[y] += par[x];
        par[x] = y;
      } else {
        par[x] += par[y];
        par[y] = x;
        if (rank[x] == rank[y]) rank[x]++;
      }
    }
  }
  ll size(ll x) { return -par[root(x)]; }
};
ll isP(ll n) {
  if (n <= 1) return 0;
  for (ll i = (2); i <= (ll)((ll)sqrt(n) + 1); i++) {
    if (n % i == 0) return 0;
  }
  return 1;
}
vvll CombMemo(3000, vll(3000, -1));
ll Comb(ll n, ll k) {
  if ((n < 0) || (k < 0)) return 0;
  if (CombMemo[n][k] == -1) {
    if (n < k)
      CombMemo[n][k] = 0;
    else {
      if (n == 0)
        CombMemo[n][k] = 1;
      else if (k == 0)
        CombMemo[n][k] = 1;
      else if (n == k)
        CombMemo[n][k] = 1;
      else
        CombMemo[n][k] = Comb(n - 1, k - 1) + Comb(n - 1, k);
    }
  }
  return CombMemo[n][k];
}
void Solve();
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;
  Solve();
}
void Solve() {
  ll n, m;
  Input(n, m);
  ;
  vll s, c;
  vInput(m, s, c);
  ;
  vll a(n, -1);
  for (ll(i) = (0); (i) <= (ll)((ll)(m)-1); (i)++) {
    s[i]--;
  }
  for (ll(i) = (0); (i) <= (ll)((ll)(m)-1); (i)++) {
    if (s[i] == 0 && c[i] == 0) {
      cout << -1;
      return;
    }
    if (a[s[i]] == -1) {
      a[s[i]] = c[i];
    } else if (a[s[i]] != c[i]) {
      cout << -1;
      return;
    }
  }
  for (ll(i) = (0); (i) <= (ll)((ll)(n)-1); (i)++) {
    if (a[i] == -1) {
      if (i) {
        cout << 0;
      } else {
        cout << 1;
      }
    } else {
      cout << a[i];
    }
  }
}
