#include <stdio.h>
#include <stdlib.h>
#include <time.h>

const int N=1000;
const int P=10000;
const unsigned int P8=256;

void print_ip (unsigned int ip) {
  unsigned int a,b,c,d;
  d = ip % 256; ip /=256;
  c = ip % 256; ip /=256;
  b = ip % 256; ip /=256;
  a = ip % 256;
  printf("%u.%u.%u.%u",a,b,c,d);
}


int main(void)
{
  srand(time(NULL));

  //генерируем таблицу маршрутизации
  printf("%d\n",N);
  unsigned int gw=16777216;
  for (int i=0; i<N; i++) {
    unsigned int a = rand()%P8; unsigned int b = rand()%P8; 
    unsigned int c = rand()%P8; unsigned int d = rand()%P8;
    if (a==0) a=1;
    unsigned int addr = ((a*P8+b)*P8+c)*P8+d;
    unsigned int mlen = 32;
    unsigned int mask=0;
    unsigned int metr=rand() % 20;
    for (unsigned int j=0; j<mlen; j++) mask = mask*2+1;
    for (unsigned int j=mlen; j<32; j++) mask *=2;
    addr &= mask;
    gw++;
    print_ip(addr); printf(" ");
    print_ip(mask); printf(" ");
    print_ip(gw); printf(" %u\n",metr);
  }

  //генерируем различные пакеты
  printf("%d\n",P);
  for (int i=0; i<P; i++) {
    unsigned int a = rand()%P8; unsigned int b = rand()%P8; 
    unsigned int c = rand()%P8; unsigned int d = rand()%P8;
    if (a==0) a=1;
    unsigned int addr = ((a*P8+b)*P8+c)*P8+d;
    print_ip(addr); printf("\n");
    
  }

  return 0;
}
