#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
long long mod(long long x, long long md) { return ((x % md) + md) % md; }
class Mint {
 public:
  static long long md;
  long long x;
  Mint(long long _x) { x = mod(_x, md); }
  Mint(const Mint &y) { x = mod(y.x, md); }
};
void MintMyExgcd(long long a, long long b, long long &x, long long &y) {
  long long md = Mint::md;
  if (b == 0) {
    y = 0;
    x = 1;
    return;
  }
  MintMyExgcd(b, a % b, x, y);
  long long t = y;
  y = mod(x - (a / b) * y, md);
  x = t;
}
long long MintNY(long long x) {
  if (x == 0) {
    return 1;
  }
  long long md = Mint::md;
  long long a, b;
  MintMyExgcd(x, md, a, b);
  while (a < 0) {
    a += md;
  }
  return a;
}
Mint operator+(Mint a, Mint b) { return Mint(mod(a.x + b.x, Mint::md)); }
Mint operator-(Mint a, Mint b) { return Mint(mod(a.x - b.x, Mint::md)); }
Mint operator*(Mint a, Mint b) { return Mint(mod(a.x * b.x, Mint::md)); }
Mint operator/(Mint a, Mint b) {
  Mint c = Mint(MintNY(b.x));
  return Mint(mod(a.x * c.x, Mint::md));
}
Mint operator-(Mint a) { return Mint(-a.x); }
bool operator==(Mint a, Mint b) { return a.x == b.x; }
bool operator!=(Mint a, Mint b) { return a.x != b.x; }
bool operator>(Mint a, Mint b) { return a.x > b.x; }
bool operator<(Mint a, Mint b) { return a.x < b.x; }
bool operator>=(Mint a, Mint b) { return a.x >= b.x; }
bool operator<=(Mint a, Mint b) { return a.x <= b.x; }
void operator+=(Mint &a, Mint b) { a = a + b; }
void operator-=(Mint &a, Mint b) { a = a - b; }
void operator*=(Mint &a, Mint b) { a = a * b; }
void operator/=(Mint &a, Mint b) { a = a / b; }
ostream &operator<<(ostream &out, Mint a) {
  out << a.x;
  return out;
}
istream &operator>>(istream &in, Mint &a) {
  in >> a.x;
  return in;
}
Mint factorial(long long n) {
  if (n == 0) {
    return Mint(1);
  }
  Mint res = 1;
  for (long long i = 1; i <= n; ++i) {
    res *= i;
  }
  return res;
}
Mint multiRange(long long s, long long t) {
  Mint res = 1;
  for (long long i = s; i <= t; ++i) {
    res *= i;
  }
  return res;
}
Mint getC(long long n, long long k) {
  if (n - k < k) {
    return getC(n, n - k);
  }
  return multiRange(n - k + 1, n) / factorial(k);
}
Mint getA(long long n, long long k) { return multiRange(n - k + 1, n); }
Mint countNonNegativeDivision(long long n, long long k) {
  return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(long long n, long long k) {
  if (n < k) {
    return 0;
  }
  if (k <= 0) {
    return 0;
  }
  return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, long long b) {
  Mint res = 1;
  while (b > 0) {
    if (b % 2) {
      res *= a;
    }
    a *= a;
    b /= 2;
  }
  return res;
}
long long Mint::md = 1000000007;
int main() {
  vector<int> res;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    res.push_back(-1);
  }
  int s, c;
  for (int i = 0; i < m; ++i) {
    cin >> s >> c;
    if (res[s - 1] != -1) {
      if (res[s - 1] == c) {
      } else {
        cout << (-1) << endl;
        return 0;
      }
    } else {
      res[s - 1] = c;
    }
  }
  if (res[0] == 0) {
    if (n == 1) {
      cout << 0 << endl;
      return 0;
    } else {
      cout << (-1) << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (res[i] == -1) {
      if (i == 0) {
        res[i] = 1;
      } else {
        res[i] = 0;
      }
    }
    cout << res[i];
  }
  cout << endl;
  return 0;
}
