#include <fstream>

using namespace std;
ifstream fi("bai1_13.inp");
ofstream fo("bai1_13.out");

int ucln(int a, int b)
{
    while (b > 0)
    {
        int r = a%b;
        a = b;
        b = r;
    }
    return a;
}

int main()
{
    ios::sync_with_stdio(false);
    int n,m,a[100000],b[100000],d=0;
    fi >> n >> m;
    a[0] = 0; b[0] = 0;
    for (int i = 1; i < n; i++)
        for (int j = i+1; j <= n; j++)
          if (ucln(i,j) == 1)
          {
              d++;
              a[d] = i; b[d] = j;
          }
    a[d+1] = 1;
    b[d+1] = 1;
    for (int i = 1; i < d; i++)
        for (int j = i+1; j <= d; j++)
            if (double(a[i])/double(b[i]) > double(a[j])/double(b[j]))
        {
            int tg = a[i]; a[i] = a[j]; a[j] = tg;
            tg = b[i]; b[i] = b[j]; b[j] = tg;
        }
    fo << d+2 << endl;
    if (m > d+2) fo << -1;
    else fo << a[m-1] << " " << b[m-1];
}
