import java.util.*;
import java.awt.Point;

public class Generate {
  public static void printRandShift(ArrayList<Point> pts, Random rnd) {
    int shift = rnd.nextInt(pts.size());
    for (int i = 0; i < pts.size(); i++) {
      Point pt = pts.get((i + shift) % pts.size());
      System.out.println(pt.x + " " + pt.y);
    }
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt(), bound = s.nextInt();
    Random rnd = new Random();
    int lx, hx;
    do {
      lx = rnd.nextInt(bound * 2 + 1) - bound;
      hx = rnd.nextInt(bound * 2 + 1) - bound;
    } while (lx >= hx);
    int ly, hy;
    do {
      ly = rnd.nextInt(bound * 2 + 1) - bound;
      hy = rnd.nextInt(bound * 2 + 1) - bound;
    } while (ly >= hy);
    ArrayList<Point> pts = new ArrayList<>();
    pts.add(new Point(lx, ly));
    pts.add(new Point(hx, ly));
    pts.add(new Point(hx, hy));
    pts.add(new Point(lx, hy));
    if (n == 6) {
      int corner = rnd.nextInt(4);
      int mx = rnd.nextInt(hx - lx - 1) + lx + 1;
      int my = rnd.nextInt(hy - ly - 1) + ly + 1;
      pts.remove(corner);
      switch (corner) {
        case 0:
          pts.add(corner, new Point(mx, ly));
          pts.add(corner, new Point(mx, my));
          pts.add(corner, new Point(lx, my));
          break;
        case 1:
          pts.add(corner, new Point(hx, my));
          pts.add(corner, new Point(mx, my));
          pts.add(corner, new Point(mx, ly));
          break;
        case 2:
          pts.add(corner, new Point(mx, hy));
          pts.add(corner, new Point(mx, my));
          pts.add(corner, new Point(hx, my));
          break;
        case 3:
          pts.add(corner, new Point(lx, my));
          pts.add(corner, new Point(mx, my));
          pts.add(corner, new Point(mx, hy));
          break;
      }
    } else if (n != 4) {
      System.out.println("n must be 4 or 6");
      System.exit(1);
    }
    System.out.println(n);
    printRandShift(pts, rnd);
  }  
}
