typedef unsigned char __u_char;
typedef unsigned short int __u_short;
typedef unsigned int __u_int;
typedef unsigned long int __u_long;
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef signed short int __int16_t;
typedef unsigned short int __uint16_t;
typedef signed int __int32_t;
typedef unsigned int __uint32_t;
typedef signed long int __int64_t;
typedef unsigned long int __uint64_t;
typedef long int __quad_t;
typedef unsigned long int __u_quad_t;
typedef long int __intmax_t;
typedef unsigned long int __uintmax_t;
typedef unsigned long int __dev_t;
typedef unsigned int __uid_t;
typedef unsigned int __gid_t;
typedef unsigned long int __ino_t;
typedef unsigned long int __ino64_t;
typedef unsigned int __mode_t;
typedef unsigned long int __nlink_t;
typedef long int __off_t;
typedef long int __off64_t;
typedef int __pid_t;
typedef struct { int __val[2]; } __fsid_t;
typedef long int __clock_t;
typedef unsigned long int __rlim_t;
typedef unsigned long int __rlim64_t;
typedef unsigned int __id_t;
typedef long int __time_t;
typedef unsigned int __useconds_t;
typedef long int __suseconds_t;
typedef int __daddr_t;
typedef int __key_t;
typedef int __clockid_t;
typedef void * __timer_t;
typedef long int __blksize_t;
typedef long int __blkcnt_t;
typedef long int __blkcnt64_t;
typedef unsigned long int __fsblkcnt_t;
typedef unsigned long int __fsblkcnt64_t;
typedef unsigned long int __fsfilcnt_t;
typedef unsigned long int __fsfilcnt64_t;
typedef long int __fsword_t;
typedef long int __ssize_t;
typedef long int __syscall_slong_t;
typedef unsigned long int __syscall_ulong_t;
typedef __off64_t __loff_t;
typedef char *__caddr_t;
typedef long int __intptr_t;
typedef unsigned int __socklen_t;
typedef int __sig_atomic_t;
typedef __int8_t int8_t;
typedef __int16_t int16_t;
typedef __int32_t int32_t;
typedef __int64_t int64_t;
typedef __uint8_t uint8_t;
typedef __uint16_t uint16_t;
typedef __uint32_t uint32_t;
typedef __uint64_t uint64_t;
typedef signed char int_least8_t;
typedef short int int_least16_t;
typedef int int_least32_t;
typedef long int int_least64_t;
typedef unsigned char uint_least8_t;
typedef unsigned short int uint_least16_t;
typedef unsigned int uint_least32_t;
typedef unsigned long int uint_least64_t;
typedef signed char int_fast8_t;
typedef long int int_fast16_t;
typedef long int int_fast32_t;
typedef long int int_fast64_t;
typedef unsigned char uint_fast8_t;
typedef unsigned long int uint_fast16_t;
typedef unsigned long int uint_fast32_t;
typedef unsigned long int uint_fast64_t;
typedef long int intptr_t;
typedef unsigned long int uintptr_t;
typedef __intmax_t intmax_t;
typedef __uintmax_t uintmax_t;
typedef int __gwchar_t;

typedef struct
  {
    long int quot;
    long int rem;
  } imaxdiv_t;
extern intmax_t imaxabs (intmax_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom)
      __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern intmax_t strtoimax (const char *__restrict __nptr,
      char **__restrict __endptr, int __base) __attribute__ ((__nothrow__ , __leaf__));
extern uintmax_t strtoumax (const char *__restrict __nptr,
       char ** __restrict __endptr, int __base) __attribute__ ((__nothrow__ , __leaf__));
extern intmax_t wcstoimax (const __gwchar_t *__restrict __nptr,
      __gwchar_t **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__ , __leaf__));
extern uintmax_t wcstoumax (const __gwchar_t *__restrict __nptr,
       __gwchar_t ** __restrict __endptr, int __base)
     __attribute__ ((__nothrow__ , __leaf__));

typedef long unsigned int size_t;
struct _IO_FILE;
typedef struct _IO_FILE __FILE;
struct _IO_FILE;
typedef struct _IO_FILE FILE;
typedef struct
{
  int __count;
  union
  {
    unsigned int __wch;
    char __wchb[4];
  } __value;
} __mbstate_t;
typedef struct
{
  __off_t __pos;
  __mbstate_t __state;
} _G_fpos_t;
typedef struct
{
  __off64_t __pos;
  __mbstate_t __state;
} _G_fpos64_t;
typedef __builtin_va_list __gnuc_va_list;
struct _IO_jump_t; struct _IO_FILE;
typedef void _IO_lock_t;
struct _IO_marker {
  struct _IO_marker *_next;
  struct _IO_FILE *_sbuf;
  int _pos;
};
enum __codecvt_result
{
  __codecvt_ok,
  __codecvt_partial,
  __codecvt_error,
  __codecvt_noconv
};
struct _IO_FILE {
  int _flags;
  char* _IO_read_ptr;
  char* _IO_read_end;
  char* _IO_read_base;
  char* _IO_write_base;
  char* _IO_write_ptr;
  char* _IO_write_end;
  char* _IO_buf_base;
  char* _IO_buf_end;
  char *_IO_save_base;
  char *_IO_backup_base;
  char *_IO_save_end;
  struct _IO_marker *_markers;
  struct _IO_FILE *_chain;
  int _fileno;
  int _flags2;
  __off_t _old_offset;
  unsigned short _cur_column;
  signed char _vtable_offset;
  char _shortbuf[1];
  _IO_lock_t *_lock;
  __off64_t _offset;
  void *__pad1;
  void *__pad2;
  void *__pad3;
  void *__pad4;
  size_t __pad5;
  int _mode;
  char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
};
typedef struct _IO_FILE _IO_FILE;
struct _IO_FILE_plus;
extern struct _IO_FILE_plus _IO_2_1_stdin_;
extern struct _IO_FILE_plus _IO_2_1_stdout_;
extern struct _IO_FILE_plus _IO_2_1_stderr_;
typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);
typedef __ssize_t __io_write_fn (void *__cookie, const char *__buf,
     size_t __n);
typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w);
typedef int __io_close_fn (void *__cookie);
extern int __underflow (_IO_FILE *);
extern int __uflow (_IO_FILE *);
extern int __overflow (_IO_FILE *, int);
extern int _IO_getc (_IO_FILE *__fp);
extern int _IO_putc (int __c, _IO_FILE *__fp);
extern int _IO_feof (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));
extern int _IO_ferror (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));
extern int _IO_peekc_locked (_IO_FILE *__fp);
extern void _IO_flockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
extern void _IO_funlockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
extern int _IO_ftrylockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
   __gnuc_va_list, int *__restrict);
extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
    __gnuc_va_list);
extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t);
extern size_t _IO_sgetn (_IO_FILE *, void *, size_t);
extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int);
extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int);
extern void _IO_free_backup_area (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
typedef __gnuc_va_list va_list;
typedef __off_t off_t;
typedef __ssize_t ssize_t;
typedef _G_fpos_t fpos_t;
extern struct _IO_FILE *stdin;
extern struct _IO_FILE *stdout;
extern struct _IO_FILE *stderr;
extern int remove (const char *__filename) __attribute__ ((__nothrow__ , __leaf__));
extern int rename (const char *__old, const char *__new) __attribute__ ((__nothrow__ , __leaf__));
extern int renameat (int __oldfd, const char *__old, int __newfd,
       const char *__new) __attribute__ ((__nothrow__ , __leaf__));
extern FILE *tmpfile (void) ;
extern char *tmpnam (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ;
extern char *tmpnam_r (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ;
extern char *tempnam (const char *__dir, const char *__pfx)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;
extern int fclose (FILE *__stream);
extern int fflush (FILE *__stream);
extern int fflush_unlocked (FILE *__stream);
extern FILE *fopen (const char *__restrict __filename,
      const char *__restrict __modes) ;
extern FILE *freopen (const char *__restrict __filename,
        const char *__restrict __modes,
        FILE *__restrict __stream) ;
extern FILE *fdopen (int __fd, const char *__modes) __attribute__ ((__nothrow__ , __leaf__)) ;
extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
  __attribute__ ((__nothrow__ , __leaf__)) ;
extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __attribute__ ((__nothrow__ , __leaf__)) ;
extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));
extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
      int __modes, size_t __n) __attribute__ ((__nothrow__ , __leaf__));
extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
         size_t __size) __attribute__ ((__nothrow__ , __leaf__));
extern void setlinebuf (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
extern int fprintf (FILE *__restrict __stream,
      const char *__restrict __format, ...);
extern int printf (const char *__restrict __format, ...);
extern int sprintf (char *__restrict __s,
      const char *__restrict __format, ...) __attribute__ ((__nothrow__));
extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
       __gnuc_va_list __arg);
extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);
extern int vsprintf (char *__restrict __s, const char *__restrict __format,
       __gnuc_va_list __arg) __attribute__ ((__nothrow__));
extern int snprintf (char *__restrict __s, size_t __maxlen,
       const char *__restrict __format, ...)
     __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 4)));
extern int vsnprintf (char *__restrict __s, size_t __maxlen,
        const char *__restrict __format, __gnuc_va_list __arg)
     __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 0)));
extern int vdprintf (int __fd, const char *__restrict __fmt,
       __gnuc_va_list __arg)
     __attribute__ ((__format__ (__printf__, 2, 0)));
extern int dprintf (int __fd, const char *__restrict __fmt, ...)
     __attribute__ ((__format__ (__printf__, 2, 3)));
extern int fscanf (FILE *__restrict __stream,
     const char *__restrict __format, ...) ;
extern int scanf (const char *__restrict __format, ...) ;
extern int sscanf (const char *__restrict __s,
     const char *__restrict __format, ...) __attribute__ ((__nothrow__ , __leaf__));
extern int fscanf (FILE *__restrict __stream, const char *__restrict __format, ...) __asm__ ("" "__isoc99_fscanf") ;
extern int scanf (const char *__restrict __format, ...) __asm__ ("" "__isoc99_scanf") ;
extern int sscanf (const char *__restrict __s, const char *__restrict __format, ...) __asm__ ("" "__isoc99_sscanf") __attribute__ ((__nothrow__ , __leaf__));
extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
      __gnuc_va_list __arg)
     __attribute__ ((__format__ (__scanf__, 2, 0))) ;
extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
     __attribute__ ((__format__ (__scanf__, 1, 0))) ;
extern int vsscanf (const char *__restrict __s,
      const char *__restrict __format, __gnuc_va_list __arg)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__format__ (__scanf__, 2, 0)));
extern int vfscanf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vfscanf")
     __attribute__ ((__format__ (__scanf__, 2, 0))) ;
extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vscanf")
     __attribute__ ((__format__ (__scanf__, 1, 0))) ;
extern int vsscanf (const char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vsscanf") __attribute__ ((__nothrow__ , __leaf__))
     __attribute__ ((__format__ (__scanf__, 2, 0)));
extern int fgetc (FILE *__stream);
extern int getc (FILE *__stream);
extern int getchar (void);
extern int getc_unlocked (FILE *__stream);
extern int getchar_unlocked (void);
extern int fgetc_unlocked (FILE *__stream);
extern int fputc (int __c, FILE *__stream);
extern int putc (int __c, FILE *__stream);
extern int putchar (int __c);
extern int fputc_unlocked (int __c, FILE *__stream);
extern int putc_unlocked (int __c, FILE *__stream);
extern int putchar_unlocked (int __c);
extern int getw (FILE *__stream);
extern int putw (int __w, FILE *__stream);
extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
     ;
extern __ssize_t __getdelim (char **__restrict __lineptr,
          size_t *__restrict __n, int __delimiter,
          FILE *__restrict __stream) ;
extern __ssize_t getdelim (char **__restrict __lineptr,
        size_t *__restrict __n, int __delimiter,
        FILE *__restrict __stream) ;
extern __ssize_t getline (char **__restrict __lineptr,
       size_t *__restrict __n,
       FILE *__restrict __stream) ;
extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
extern int puts (const char *__s);
extern int ungetc (int __c, FILE *__stream);
extern size_t fread (void *__restrict __ptr, size_t __size,
       size_t __n, FILE *__restrict __stream) ;
extern size_t fwrite (const void *__restrict __ptr, size_t __size,
        size_t __n, FILE *__restrict __s);
extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
         size_t __n, FILE *__restrict __stream) ;
extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
          size_t __n, FILE *__restrict __stream);
extern int fseek (FILE *__stream, long int __off, int __whence);
extern long int ftell (FILE *__stream) ;
extern void rewind (FILE *__stream);
extern int fseeko (FILE *__stream, __off_t __off, int __whence);
extern __off_t ftello (FILE *__stream) ;
extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
extern int fsetpos (FILE *__stream, const fpos_t *__pos);
extern void clearerr (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
extern int feof (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
extern int ferror (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
extern void clearerr_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
extern int feof_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
extern int ferror_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
extern void perror (const char *__s);
extern int sys_nerr;
extern const char *const sys_errlist[];
extern int fileno (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
extern int fileno_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
extern FILE *popen (const char *__command, const char *__modes) ;
extern int pclose (FILE *__stream);
extern char *ctermid (char *__s) __attribute__ ((__nothrow__ , __leaf__));
extern void flockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));

typedef int wchar_t;

typedef enum
{
  P_ALL,
  P_PID,
  P_PGID
} idtype_t;
typedef struct
  {
    int quot;
    int rem;
  } div_t;
typedef struct
  {
    long int quot;
    long int rem;
  } ldiv_t;
__extension__ typedef struct
  {
    long long int quot;
    long long int rem;
  } lldiv_t;
extern size_t __ctype_get_mb_cur_max (void) __attribute__ ((__nothrow__ , __leaf__)) ;
extern double atof (const char *__nptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;
extern int atoi (const char *__nptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;
extern long int atol (const char *__nptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;
__extension__ extern long long int atoll (const char *__nptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;
extern double strtod (const char *__restrict __nptr,
        char **__restrict __endptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern float strtof (const char *__restrict __nptr,
       char **__restrict __endptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern long double strtold (const char *__restrict __nptr,
       char **__restrict __endptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern long int strtol (const char *__restrict __nptr,
   char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern unsigned long int strtoul (const char *__restrict __nptr,
      char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
__extension__
extern long long int strtoq (const char *__restrict __nptr,
        char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
__extension__
extern unsigned long long int strtouq (const char *__restrict __nptr,
           char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
__extension__
extern long long int strtoll (const char *__restrict __nptr,
         char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
__extension__
extern unsigned long long int strtoull (const char *__restrict __nptr,
     char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern char *l64a (long int __n) __attribute__ ((__nothrow__ , __leaf__)) ;
extern long int a64l (const char *__s)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;

typedef __u_char u_char;
typedef __u_short u_short;
typedef __u_int u_int;
typedef __u_long u_long;
typedef __quad_t quad_t;
typedef __u_quad_t u_quad_t;
typedef __fsid_t fsid_t;
typedef __loff_t loff_t;
typedef __ino_t ino_t;
typedef __dev_t dev_t;
typedef __gid_t gid_t;
typedef __mode_t mode_t;
typedef __nlink_t nlink_t;
typedef __uid_t uid_t;
typedef __pid_t pid_t;
typedef __id_t id_t;
typedef __daddr_t daddr_t;
typedef __caddr_t caddr_t;
typedef __key_t key_t;
typedef __clock_t clock_t;
typedef __clockid_t clockid_t;
typedef __time_t time_t;
typedef __timer_t timer_t;
typedef unsigned long int ulong;
typedef unsigned short int ushort;
typedef unsigned int uint;
typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));
typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));
typedef int register_t __attribute__ ((__mode__ (__word__)));
static __inline unsigned int
__bswap_32 (unsigned int __bsx)
{
  return __builtin_bswap32 (__bsx);
}
static __inline __uint64_t
__bswap_64 (__uint64_t __bsx)
{
  return __builtin_bswap64 (__bsx);
}
static __inline __uint16_t
__uint16_identity (__uint16_t __x)
{
  return __x;
}
static __inline __uint32_t
__uint32_identity (__uint32_t __x)
{
  return __x;
}
static __inline __uint64_t
__uint64_identity (__uint64_t __x)
{
  return __x;
}
typedef struct
{
  unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
} __sigset_t;
typedef __sigset_t sigset_t;
struct timeval
{
  __time_t tv_sec;
  __suseconds_t tv_usec;
};
struct timespec
{
  __time_t tv_sec;
  __syscall_slong_t tv_nsec;
};
typedef __suseconds_t suseconds_t;
typedef long int __fd_mask;
typedef struct
  {
    __fd_mask __fds_bits[1024 / (8 * (int) sizeof (__fd_mask))];
  } fd_set;
typedef __fd_mask fd_mask;

extern int select (int __nfds, fd_set *__restrict __readfds,
     fd_set *__restrict __writefds,
     fd_set *__restrict __exceptfds,
     struct timeval *__restrict __timeout);
extern int pselect (int __nfds, fd_set *__restrict __readfds,
      fd_set *__restrict __writefds,
      fd_set *__restrict __exceptfds,
      const struct timespec *__restrict __timeout,
      const __sigset_t *__restrict __sigmask);

extern unsigned int gnu_dev_major (__dev_t __dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern unsigned int gnu_dev_minor (__dev_t __dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern __dev_t gnu_dev_makedev (unsigned int __major, unsigned int __minor) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));

typedef __blksize_t blksize_t;
typedef __blkcnt_t blkcnt_t;
typedef __fsblkcnt_t fsblkcnt_t;
typedef __fsfilcnt_t fsfilcnt_t;
struct __pthread_rwlock_arch_t
{
  unsigned int __readers;
  unsigned int __writers;
  unsigned int __wrphase_futex;
  unsigned int __writers_futex;
  unsigned int __pad3;
  unsigned int __pad4;
  int __cur_writer;
  int __shared;
  signed char __rwelision;
  unsigned char __pad1[7];
  unsigned long int __pad2;
  unsigned int __flags;
};
typedef struct __pthread_internal_list
{
  struct __pthread_internal_list *__prev;
  struct __pthread_internal_list *__next;
} __pthread_list_t;
struct __pthread_mutex_s
{
  int __lock ;
  unsigned int __count;
  int __owner;
  unsigned int __nusers;
  int __kind;

  short __spins; short __elision;
  __pthread_list_t __list;

};
struct __pthread_cond_s
{
  __extension__ union
  {
    __extension__ unsigned long long int __wseq;
    struct
    {
      unsigned int __low;
      unsigned int __high;
    } __wseq32;
  };
  __extension__ union
  {
    __extension__ unsigned long long int __g1_start;
    struct
    {
      unsigned int __low;
      unsigned int __high;
    } __g1_start32;
  };
  unsigned int __g_refs[2] ;
  unsigned int __g_size[2];
  unsigned int __g1_orig_size;
  unsigned int __wrefs;
  unsigned int __g_signals[2];
};
typedef unsigned long int pthread_t;
typedef union
{
  char __size[4];
  int __align;
} pthread_mutexattr_t;
typedef union
{
  char __size[4];
  int __align;
} pthread_condattr_t;
typedef unsigned int pthread_key_t;
typedef int pthread_once_t;
union pthread_attr_t
{
  char __size[56];
  long int __align;
};
typedef union pthread_attr_t pthread_attr_t;
typedef union
{
  struct __pthread_mutex_s __data;
  char __size[40];
  long int __align;
} pthread_mutex_t;
typedef union
{
  struct __pthread_cond_s __data;
  char __size[48];
  __extension__ long long int __align;
} pthread_cond_t;
typedef union
{
  struct __pthread_rwlock_arch_t __data;
  char __size[56];
  long int __align;
} pthread_rwlock_t;
typedef union
{
  char __size[8];
  long int __align;
} pthread_rwlockattr_t;
typedef volatile int pthread_spinlock_t;
typedef union
{
  char __size[32];
  long int __align;
} pthread_barrier_t;
typedef union
{
  char __size[4];
  int __align;
} pthread_barrierattr_t;

extern long int random (void) __attribute__ ((__nothrow__ , __leaf__));
extern void srandom (unsigned int __seed) __attribute__ ((__nothrow__ , __leaf__));
extern char *initstate (unsigned int __seed, char *__statebuf,
   size_t __statelen) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
extern char *setstate (char *__statebuf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
struct random_data
  {
    int32_t *fptr;
    int32_t *rptr;
    int32_t *state;
    int rand_type;
    int rand_deg;
    int rand_sep;
    int32_t *end_ptr;
  };
extern int random_r (struct random_data *__restrict __buf,
       int32_t *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern int srandom_r (unsigned int __seed, struct random_data *__buf)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
   size_t __statelen,
   struct random_data *__restrict __buf)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4)));
extern int setstate_r (char *__restrict __statebuf,
         struct random_data *__restrict __buf)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern int rand (void) __attribute__ ((__nothrow__ , __leaf__));
extern void srand (unsigned int __seed) __attribute__ ((__nothrow__ , __leaf__));
extern int rand_r (unsigned int *__seed) __attribute__ ((__nothrow__ , __leaf__));
extern double drand48 (void) __attribute__ ((__nothrow__ , __leaf__));
extern double erand48 (unsigned short int __xsubi[3]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern long int lrand48 (void) __attribute__ ((__nothrow__ , __leaf__));
extern long int nrand48 (unsigned short int __xsubi[3])
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern long int mrand48 (void) __attribute__ ((__nothrow__ , __leaf__));
extern long int jrand48 (unsigned short int __xsubi[3])
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern void srand48 (long int __seedval) __attribute__ ((__nothrow__ , __leaf__));
extern unsigned short int *seed48 (unsigned short int __seed16v[3])
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern void lcong48 (unsigned short int __param[7]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
struct drand48_data
  {
    unsigned short int __x[3];
    unsigned short int __old_x[3];
    unsigned short int __c;
    unsigned short int __init;
    __extension__ unsigned long long int __a;
  };
extern int drand48_r (struct drand48_data *__restrict __buffer,
        double *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern int erand48_r (unsigned short int __xsubi[3],
        struct drand48_data *__restrict __buffer,
        double *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern int lrand48_r (struct drand48_data *__restrict __buffer,
        long int *__restrict __result)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern int nrand48_r (unsigned short int __xsubi[3],
        struct drand48_data *__restrict __buffer,
        long int *__restrict __result)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern int mrand48_r (struct drand48_data *__restrict __buffer,
        long int *__restrict __result)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern int jrand48_r (unsigned short int __xsubi[3],
        struct drand48_data *__restrict __buffer,
        long int *__restrict __result)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
extern int seed48_r (unsigned short int __seed16v[3],
       struct drand48_data *__buffer) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern int lcong48_r (unsigned short int __param[7],
        struct drand48_data *__buffer)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern void *malloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;
extern void *calloc (size_t __nmemb, size_t __size)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;
extern void *realloc (void *__ptr, size_t __size)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
extern void free (void *__ptr) __attribute__ ((__nothrow__ , __leaf__));

extern void *alloca (size_t __size) __attribute__ ((__nothrow__ , __leaf__));

extern void *valloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;
extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;
extern void *aligned_alloc (size_t __alignment, size_t __size)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__alloc_size__ (2))) ;
extern void abort (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));
extern int atexit (void (*__func) (void)) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern int at_quick_exit (void (*__func) (void)) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern void exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));
extern void quick_exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));
extern void _Exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));
extern char *getenv (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;
extern int putenv (char *__string) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern int setenv (const char *__name, const char *__value, int __replace)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
extern int unsetenv (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern int clearenv (void) __attribute__ ((__nothrow__ , __leaf__));
extern char *mktemp (char *__template) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern int mkstemp (char *__template) __attribute__ ((__nonnull__ (1))) ;
extern int mkstemps (char *__template, int __suffixlen) __attribute__ ((__nonnull__ (1))) ;
extern char *mkdtemp (char *__template) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;
extern int system (const char *__command) ;
extern char *realpath (const char *__restrict __name,
         char *__restrict __resolved) __attribute__ ((__nothrow__ , __leaf__)) ;
typedef int (*__compar_fn_t) (const void *, const void *);
extern void *bsearch (const void *__key, const void *__base,
        size_t __nmemb, size_t __size, __compar_fn_t __compar)
     __attribute__ ((__nonnull__ (1, 2, 5))) ;
extern void qsort (void *__base, size_t __nmemb, size_t __size,
     __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4)));
extern int abs (int __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;
extern long int labs (long int __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;
__extension__ extern long long int llabs (long long int __x)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;
extern div_t div (int __numer, int __denom)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;
extern ldiv_t ldiv (long int __numer, long int __denom)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;
__extension__ extern lldiv_t lldiv (long long int __numer,
        long long int __denom)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;
extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ;
extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ;
extern char *gcvt (double __value, int __ndigit, char *__buf)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3))) ;
extern char *qecvt (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ;
extern char *qfcvt (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ;
extern char *qgcvt (long double __value, int __ndigit, char *__buf)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3))) ;
extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign, char *__restrict __buf,
     size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));
extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign, char *__restrict __buf,
     size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));
extern int qecvt_r (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign,
      char *__restrict __buf, size_t __len)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));
extern int qfcvt_r (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign,
      char *__restrict __buf, size_t __len)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));
extern int mblen (const char *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__));
extern int mbtowc (wchar_t *__restrict __pwc,
     const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__ , __leaf__));
extern int wctomb (char *__s, wchar_t __wchar) __attribute__ ((__nothrow__ , __leaf__));
extern size_t mbstowcs (wchar_t *__restrict __pwcs,
   const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__ , __leaf__));
extern size_t wcstombs (char *__restrict __s,
   const wchar_t *__restrict __pwcs, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__));
extern int rpmatch (const char *__response) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;
extern int getsubopt (char **__restrict __optionp,
        char *const *__restrict __tokens,
        char **__restrict __valuep)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2, 3))) ;
extern int getloadavg (double __loadavg[], int __nelem)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));

extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
       size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern void *memmove (void *__dest, const void *__src, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern void *memccpy (void *__restrict __dest, const void *__restrict __src,
        int __c, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern void *memset (void *__s, int __c, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern int memcmp (const void *__s1, const void *__s2, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
extern void *memchr (const void *__s, int __c, size_t __n)
      __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern char *strncpy (char *__restrict __dest,
        const char *__restrict __src, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern char *strcat (char *__restrict __dest, const char *__restrict __src)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern char *strncat (char *__restrict __dest, const char *__restrict __src,
        size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern int strcmp (const char *__s1, const char *__s2)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
extern int strncmp (const char *__s1, const char *__s2, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
extern int strcoll (const char *__s1, const char *__s2)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
extern size_t strxfrm (char *__restrict __dest,
         const char *__restrict __src, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
struct __locale_struct
{
  struct __locale_data *__locales[13];
  const unsigned short int *__ctype_b;
  const int *__ctype_tolower;
  const int *__ctype_toupper;
  const char *__names[13];
};
typedef struct __locale_struct *__locale_t;
typedef __locale_t locale_t;
extern int strcoll_l (const char *__s1, const char *__s2, locale_t __l)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));
extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n,
    locale_t __l) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4)));
extern char *strdup (const char *__s)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));
extern char *strndup (const char *__string, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));
extern char *strchr (const char *__s, int __c)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
extern char *strrchr (const char *__s, int __c)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
extern size_t strcspn (const char *__s, const char *__reject)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
extern size_t strspn (const char *__s, const char *__accept)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
extern char *strpbrk (const char *__s, const char *__accept)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
extern char *strstr (const char *__haystack, const char *__needle)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
extern char *strtok (char *__restrict __s, const char *__restrict __delim)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
extern char *__strtok_r (char *__restrict __s,
    const char *__restrict __delim,
    char **__restrict __save_ptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
extern char *strtok_r (char *__restrict __s, const char *__restrict __delim,
         char **__restrict __save_ptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
extern size_t strlen (const char *__s)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
extern size_t strnlen (const char *__string, size_t __maxlen)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
extern char *strerror (int __errnum) __attribute__ ((__nothrow__ , __leaf__));
extern int strerror_r (int __errnum, char *__buf, size_t __buflen) __asm__ ("" "__xpg_strerror_r") __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
extern char *strerror_l (int __errnum, locale_t __l) __attribute__ ((__nothrow__ , __leaf__));

extern int bcmp (const void *__s1, const void *__s2, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
extern void bcopy (const void *__src, void *__dest, size_t __n)
  __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern void bzero (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern char *index (const char *__s, int __c)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
extern char *rindex (const char *__s, int __c)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
extern int ffs (int __i) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern int ffsl (long int __l) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
__extension__ extern int ffsll (long long int __ll)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern int strcasecmp (const char *__s1, const char *__s2)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));
extern int strncasecmp_l (const char *__s1, const char *__s2,
     size_t __n, locale_t __loc)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 4)));

extern void explicit_bzero (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern char *strsep (char **__restrict __stringp,
       const char *__restrict __delim)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern char *strsignal (int __sig) __attribute__ ((__nothrow__ , __leaf__));
extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern char *stpcpy (char *__restrict __dest, const char *__restrict __src)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern char *__stpncpy (char *__restrict __dest,
   const char *__restrict __src, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern char *stpncpy (char *__restrict __dest,
        const char *__restrict __src, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));

static struct cmc_alloc_node
{
    void *(*malloc)(size_t);
    void *(*calloc)(size_t, size_t);
    void *(*realloc)(void *, size_t);
    void (*free)(void *);
} cmc_alloc_node_default = { malloc, calloc, realloc, free };
struct cmc_callbacks
{
    void (*create)(void);
    void (*read)(void);
    void (*update)(void);
    void (*delete)(void);
    void (*resize)(void);
};
enum cmc_flags
{
    CMC_FLAG_OK = 0,
    CMC_FLAG_ALLOC = 1,
    CMC_FLAG_EMPTY = 2,
    CMC_FLAG_NOT_FOUND = 3,
    CMC_FLAG_INVALID = 4,
    CMC_FLAG_RANGE = 5,
    CMC_FLAG_DUPLICATE = 6,
    CMC_FLAG_ERROR = 7,
    CMC_FLAG_THREAD = 8,
    CMC_FLAG_MUTEX = 9
};
__attribute__((__unused__)) static const char *cmc_flags_to_str[10] = { "OK", "ALLOC", "EMPTY", "NOT_FOUND", "INVALID",
                                                       "RANGE", "DUPLICATE", "ERROR", "THREAD", "MUTEX" };
struct fragment {
 long len;
 long b;
};
static inline int fragment_compare(struct fragment f1, struct fragment f2) {
 if (f1.len < f2.len) {
  return -1;
 } else if (f1.len > f2.len) {
  return 1;
 }
 return f1.b - f2.b;
}
C_MACRO_COLLECTIONS_ALL(CMC, TREESET, (ls, lset, , , long))
C_MACRO_COLLECTIONS_ALL(CMC, TREESET, (fs, fset, , , struct fragment));
C_MACRO_COLLECTIONS_ALL(CMC, TREEMAP, (tm, treemap, , long, long))
long moves(struct lset *piles, struct fset *fragments) {
 long max_pile, min_pile;
 ls_max(piles, &max_pile);
 ls_min(piles, &min_pile);
 struct fragment max_frag;
 fs_max(fragments, &max_frag);
 return max_pile - min_pile - max_frag.len;
}
static struct lset_node* lset_impl_get_node(struct lset * _set_, long value) {
    struct lset_node *scan = _set_->root;
    while (scan != ((void *)0)) {
        if (_set_->f_val->cmp(scan->value, value) > 0)
            scan = scan->left;
        else if (_set_->f_val->cmp(scan->value, value) < 0)
            scan = scan->right;
        else
            return scan;
    }
    return ((void *)0);
}
static struct lset_node* lset_impl_get_node_gte(struct lset_node *nd, long value) {
 if (nd == ((void *)0) || nd->value == value) {
  return nd;
 }
 if (nd->value < value) {
  return lset_impl_get_node_gte(nd->right, value);
 }
 struct lset_node *nd_gte = lset_impl_get_node_gte(nd->left, value);
 if (nd_gte) {
  return nd_gte;
 }
 return nd;
}
static struct lset_node* lset_impl_tree_min(struct lset_node* nd) {
 if (nd->left != ((void *)0)) {
  return lset_impl_tree_min(nd->left);
 }
 return nd;
}
static struct lset_node* lset_impl_tree_max(struct lset_node* nd) {
 if (nd->right != ((void *)0)) {
  return lset_impl_tree_max(nd->right);
 }
 return nd;
}
static struct lset_node* lset_impl_tree_predecessor(struct lset_node* nd) {
 if (nd->left != ((void *)0)) {
  return lset_impl_tree_max(nd->left);
 }
 struct lset_node* par = nd->parent;
 while (par != ((void *)0) && nd == par->left) {
  nd = par;
  par = par->parent;
 }
 return par;
}
static struct lset_node* lset_impl_tree_successor(struct lset_node* nd) {
 if (nd->right != ((void *)0)) {
  return lset_impl_tree_min(nd->right);
 }
 struct lset_node* par = nd->parent;
 while (par != ((void *)0) && nd == par->right) {
  nd = par;
  par = par->right;
 }
 return par;
}
int main() {
 struct lset *piles = ls_new(&(struct lset_fval){
  .cmp = cmc_i64_cmp
 });
 int n, q;
 scanf("%d%d", &n, &q);
 for (int i = 0; i < n; ++i) {
  long pile;
  scanf("%ld", &pile);
  ls_insert(piles, pile);
 }
 struct fset *fragments = fs_new(&(struct fset_fval){
  .cmp = fragment_compare
 });
 {
  long b, e;
  struct lset_iter it = ls_iter_start(piles);
  for (;!ls_iter_at_end(&it); ls_iter_next(&it)) {
   if (ls_iter_at_start(&it)) {
    b = ls_iter_value(&it);
   } else {
    e = ls_iter_value(&it);
    fs_insert(fragments, (struct fragment){e - b, b});
    b = e;
   }
  }
 }
 printf("%ld\n", moves(piles, fragments));
 for (int i = 0; i < q; ++i) {
  long t, x;
  scanf("%ld%ld", &t, &x);
  if (t == 0) {
  }
 }
 return 0;
}


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

int ***sol;
int N, K;
const int kInvalidSol = -10000;
void new_sol() {
	sol = (int***)malloc(sizeof(int**) * (N + 1));
	for (int n = 0; n <= N; ++n) {
		sol[n] = (int**)malloc(sizeof(int*) * (K + 1));
		for (int k = 0; k <= K; ++k) {
			sol[n][k] = (int*)malloc(sizeof(int) * (N + 1));
			for (int i = 0; i <= N; ++i) {
				sol[n][k][i] = kInvalidSol;
			}
		}
	}
}
void free_sol() {
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= K; ++j) {
			free(sol[i][j]);
		}
		free(sol[i]);
	}
	free(sol);
}
void try_update_sol(int n, int k, int i, int value) {
	if (value >= 0 && sol[n][k][i] < value) {
		sol[n][k][i] = value;
	}
}
int imax(int a, int b) {
	return a < b? b: a;
}
int main() {
	char s[201], t[3];
	scanf("%d%d\n%s\n%s", &N, &K, s, t);
	// printf("%s\t%s\n", s, t);
	new_sol();
	if (t[0] == t[1]) {
		int cc = 0;
		for (int i = 0; i < N; ++i) {
			if (s[i] == t[0]) {
				++cc;
			}
		}
		cc += K;
		if (cc > N) {
			cc = N;
		}
		printf("%d\n", cc * (cc - 1) / 2);
	} else {
		{
			int cc = 0;
			sol[0][0][0] = 0;
			for (int n = 1; n <= N; ++n) {
				if (s[n - 1] == t[0]) {
					++cc;
					if (cc == 1) {
						sol[n][0][cc] = 0;
					} else {
						try_update_sol(n, 0, cc, sol[n - 1][0][cc - 1]);
					}
				} else if (s[n - 1] == t[1]) {
					try_update_sol(n, 0, cc, sol[n - 1][0][cc] + cc);
				} else {
					try_update_sol(n, 0, cc, sol[n - 1][0][cc]);
				}
				for (int k = cc; k <= K; ++k) {
					try_update_sol(n, k, 0, 0);
				}
			}
		}
		// printf("sol k = 0\n");
		// for (int n = 1; n <= N; ++n) {
		// 	for (int i = 1; i <= n; ++i) {
		// 		printf("%d\t", sol[n][0][i]);
		// 	}
		// 	printf("\n");
		// }
		// for (int k = 1; k <= K; ++k) {
		// 	sol[1][k][1] = 0;
		// 	int cc = s[0] == t[0]? 1: 0;
		// 	for (int n = 2; n <= N; ++n) {
		// 		try_update_sol(n, k, 1, sol[n][k-1][1]);
		// 		if (s[n - 1] == t[0]) {
		// 			++cc;
		// 			try_update_sol(n, k, 1, sol[n - 1][k - 1][1] + 1);
		// 		} else if (s[n - 1] == t[1]) {
		// 			try_update_sol(n, k, 1, sol[n - 1][k][1] + 1);
		// 		} else {
		// 			try_update_sol(n, k, 1, sol[n - 1][k][1]);
		// 			try_update_sol(n, k, 1, sol[n - 1][k - 1][1] + 1);
		// 		}
		// 	}
		// }
		// printf("sol with i = 1\n");
		// for (int n = 1; n <= N; ++n) {
		// 	for (int k = 0; k <= K; ++k) {
		// 		printf("%d\t", sol[n][k][1]);
		// 	}
		// 	printf("\n");
		// }
		for (int k = 1; k <= K; ++k) {
			try_update_sol(1, k, 1, 0);
			for (int n = 2; n <= N; ++n) {
				for (int i = 1; i <= n; ++i) {
					try_update_sol(n, k, i, sol[n][k - 1][i]);
					if (s[n - 1] == t[0]) {
						try_update_sol(n, k, i, sol[n - 1][k][i - 1]);
						try_update_sol(n, k, i, sol[n - 1][k - 1][i] + i);
					} else if (s[n - 1] == t[1]) {
						try_update_sol(n, k, i, sol[n - 1][k][i] + i);
						try_update_sol(n, k, i, sol[n - 1][k - 1][i - 1]);
					} else {
							try_update_sol(n, k, i, sol[n - 1][k - 1][i - 1]);
							try_update_sol(n, k, i, sol[n - 1][k - 1][i] + i);
					}
				}
			}
			// printf("sol k = %d\n", k);
			// for (int n = 1; n <= N; ++n) {
			// 	for (int i = 1; i <= n; ++i) {
			// 		printf("%d\t", sol[n][k][i]);
			// 	}
			// 	printf("\n");
			// }
		}
		int max = 0;
		for (int i = 1; i <= N; ++i) {
			if (sol[N][K][i] > max) {
				max = sol[N][K][i];
			}
		}
		printf("%d\n", max);
		free_sol();
	}
	return 0;
}


#include<stdio.h>
int main()
{
	long long int n,count=0,t,i,q,sum;
	scanf("%lld",&n);
	t=n/5;
	for(i=1;i<t+2;i++)
	{
		if((n+i)%3==0)
		{
			sum=((i)*(i+1))/2;
			q=(n+i)/3;
			if(q>=sum)
				count++;
		}
	}
	printf("%lld\n",count);
	return 0;
}


#include<stdio.h>
#include<stdio.h>
int main()
{
	long long n,m,k,a,min,max;
	scanf("%lld %lld",&n,&m);
	for(a=0;a<=m;a++)
	{
		k=a*(a-1);
		if(k>=(2*m))
			break;
	}
	max=n-a;
	min=n-2*m;
	if(min<0)
		min=0;
	printf("%lld %lld\n",min,max);
}
/*
int factorial(int n)
    {
        int ans=n;
        for(int i=n-1;i>0;i++)
        {
            ans*=i;
        }
        return ans;
    }
int main()
    {
        int vertex,edges,min=0,max=0;
        scanf("%d",&vertex);
        scanf("%d",&edges);

        max=(vertex/2-edges)*2;
        min=factorial(vertex)/(factorial(vertex-2)*2)
        if(vertex%2==0)
            {

                printf("%d ",max);
            }
        else
            {
                printf("%d",max+1);
            }

    }
/*


#include <stdio.h>
#include <string.h>
int main()
{
    char pass[101];
    int l=0,s=0,d=0;
    scanf("%s", pass);
    int i=0;
    if(strlen(pass)<5) {
        return;
    }
    while(pass[i])
    {
        if(pass[i]>='a' && pass[i]<='z')s=1;
        if(pass[i]>='A' && pass[i]<='Z')l=1;
        if(pass[i]>='0' && pass[i]<='9')d=1;
        i++;
    }
    if(s==1 && l==1 && d==1){
            printf("Correct");
    }
    else printf("Too weak");
}


#include <iostream>
#include<stdio.h>
#include<stack>
#include<math.h>
#include<algorithm>
#include<string.h>
#include<queue>
using namespace std;
typedef long long ll;
const ll INF=0x3f3f3f3f;
ll k,kmax,kmin,t,m,i,j,l,n,x,y,z;
char a[100000+5],b[100000+5],o[2000];
int main()
{
    scanf("%lld%lld%lld",&x,&y,&z);
    ll sum=0;
    t=0;
    ll g=1;
    ll j=1;
    for(i=1;; i*=2)
    {
        sum+=i;
        if(j==y)
            break;
        j++;
    }
    sum+=x-y;
    ll min1,max2;
    min1=sum;
    sum=0;
    j=1;
    for(i=1;; i*=2)
    {
        sum+=i;
        if(j==z)
            break;
        j++;
    }
    sum+=(x-z)*i;
    max2=sum;
    printf("%lld %lld\n",min1,max2);
}


#include<stdio.h>
int main(){
    long int n,m,i,temp1,temp2;
    scanf("%ld%ld",&n,&m);
    long int a[n];
    for(i=0;i<=n;i++)
    a[i]=0;
    for(i=0;i<m;i++){
    scanf("%ld %ld",&temp1,&temp2);
    a[temp1]=1;a[temp2]=1;
    }
    printf("%ld\n",n-1);
    for(i=1;i<=n;i++){
        if(a[i]==0){
        temp1=i;
        break;
        }
    }
    for(i=1;i<=n;i++){
        if(i!=temp1)
        printf("%ld %ld\n",i,temp1);
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,t,k,d;
    scanf("%d%d%d%d",&n,&t,&k,&d);
    int q,r,time;
    if(d>t)
    {
        q=d/t;
        n=n-q*k;
        if(n<=0)
        {printf("NO");exit(1);}
        else
        {
            if(n>k)printf("YES");
        else printf("NO");
        }
    }
    else if(d<t)
    {
        if(n==k)printf("NO");
    else printf("YES");
    }
else if(d==t)
{
    n=n-k;
    if(n<=k)printf("NO");
else printf("YES");
}
}


#include <stdio.h>
int test(char a[4][4],int i,int j){
	int count1=0,count2=0,k,l;
	for(k=0;k<2;k++){
		for(l=0;l<2;l++){
			if(a[i+k][j+l]=='#'){
				count1++;
			}
			else{
				count2++;
			}
		}
	}
	if(count1>=3){
		return 1;
	}
	else if(count2>=3){
		return 1;
	}
	else{
		return 0;
	}
}
int main(){
	int i,j;
	char arr[4][4];
	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			scanf(" %c",&arr[i][j]);
			//printf("aa\n");
		}
	}

	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			if(test(arr,i,j)){
				printf("YES\n");
				return 1;
			}
		}
	}
	printf("NO\n");
}


#include <stdio.h>
main()
{
int n,m;
scanf("%d %d",&n,&m);
int i,j,k;
for(i=n+1;i<=m;i++)
{
for(j=2;j<=i/2;j++)
{
if(i%j==0)
break;

}
if(j==(i/2+1))
{
if(i==m)
{printf("YES");
return;}
else
{printf("NO");
return;}

}

}
printf("NO");

}


#include <stdio.h>
#include <stdlib.h>
int main(void)
{
		int n,a,b,c,d;
		int ul,ur,mid,dl,dr;
		int possible1,possible2 = 0;
		int min = 400001;
		int max = -1;
		int i,j,k,temp;
		int sq[4] = {0,};
		scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);

		sq[0] = a+b;
		sq[1] = a+c;
		sq[2] = b+d;
		sq[3] = c+d;

		for(i=0;i<4;i++)
		{
			if( sq[i]+2 <= min )
					min = sq[i]+2;

			if( sq[i] + 2*n >= max )
					max = sq[i] + 2*n;
		}

		for( i = min; i <= max; i++)
		{
			for(j = 1; j <= n; j++)
			{

				for(k=0;k<4;k++)
				{
						temp = i - (sq[k]+j);
//						printf("temp:%d\n",temp);
						if( temp > 0 && temp <= n)
								possible1++;

				}
				if( possible1 == 4 )
				{
					possible2++;
				}

				possible1 = 0;
			}
		}
		printf("%d\n",possible2);
		return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    int n,h,s,i,j;
    scanf("%d%d%d",&n,&h,&s);
    int l[s],r[s],x[s],b[s];
    for(i=0;i<s;i++)
    {
        scanf("%d%d%d",&l[i],&r[i],&x[i]);
    }
    int sum=0;
    for(i=0;i<n;i++)
    {
        int w=0;
        b[i]=1000000000;
        //finding maximum restriction for building i for l//
        for(j=0;j<s;j++)
        {
            if((i+1)==l[j])
            {
                w=1;
                if(b[i]<=x[j])
                {
                    continue;
                }
                else
                {
                    b[i]=x[j];
                }
                break;
            }
            else
            {
                continue;
            }
        }
        //finding maximum restriction for building i for r//
        for(j=0;j<s;j++)
        {
            if((i+1)==r[j])
            {
                w=1;
                if(b[i]<=x[j])
                {
                    continue;
                }
                else
                {
                    b[i]=x[j];
                }
                break;
            }
            else
            {
                continue;
            }
        }
        if(w==1)//if there is any restriction then, restricted value will be calculated//
        {
            sum+=(b[i]*b[i]);
        }
        else//no restriction, so maximum height is calculated//
        {
            sum+=(h*h);
        }
    }
    printf("%d",sum);
    return 0;
}


 #include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,h,m,l,r,x,sum=0;
    cin>>n;
    cin>>h;
    cin>>m;

    int v[n];
    for(int i=0;i<n;i++)
        v[i] = h;
    for(int i=0;i<m;i++)
    {
        cin>>l;
        cin>>r;
        cin>>x;

        for(int j = l-1;j <= r;j++)
        {
            v[j] = x;
        }
    }
    for(int i = 0;i<n;i++ )
    {
        sum += pow(v[i],2);
    }
    cout<<sum;
   return 0;
}


#include <stdio.h>
int sum(long long int x)
{
	int k=0;
	while(x>0)
	{
		k+=(x%10);
		x=x/10;
	}
	return k;
}
int main()
{
	long long int n,s;
	scanf("%lld%lld",&n,&s);
	long long int x=(s/9)*10;
	long long int flag=0,lower;
	do
	{
		long long int check=x-sum(x);
		if(check<s)
		{
			flag=1;
			lower=x+10;
		}
		else
		{
			x-=10;
		}
	}
	while(flag==0);
	long long int val=n-lower+1;
	if(val<1)printf("0");
	else printf("%lld",val);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define ll long long
int main()
{
    ll n, s;
    scanf("%lld %lld", &n, &s);
    ll left = 0, right = n;
    ll sum1 = 0;
    while(right != left)
    {
        ll mid = (right + left) / 2;
         ll div = 1;
         ll sum = 0;
    while (num / div != 0)
    {
        sum+=((num)%(div*10))/div;
        div*=10;
    }
        ll check=mid-sum;
        if (check>=s)
            right=mid;
        else
            left=mid;
        if (right-left==1)
            left++;
    }
     ll div = 1;
    while (n/div!=0)
    {
        sum1+= ((num) % (div * 10)) / div;
        div *= 10;
    }
    if (n - sum1 >= s)
        printf("%lld", n - right + 1);
    else
        printf("0");
return 0;
}


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

int main()
{
    int n , l , m=0 , x , y;
    printf("enter the employees num\n");
    scanf("%d",n);
    for(l=1;l<n;l++)
    {
        x=n-l;
        y=x%l;
        if(y=0)
        {
            m++;
        }

    }
     printf("%d",m);
    return 0;
}


#include<stdio.h>
int main()
{
	long long int n,i,k=0;
	scanf("%lld",&n);
	for(i=0;i<n;i++)
		{
			if((n%i==0)&&(n>1))
			k++;
		}
		printf("%lld\n",k);

	return 0;
}


#include<stdio.h>
int main()
{
  int x,y,a;
  scanf("%d %d %d",&x,&y,&a);
  float a2=(float)a/2;
  if(y%a==0)
  {
    printf("-1");
    return 0;
  }
  int ya=y/a+1;
  float xa=x/a2;
  int num=ya+(ya-1)/2;
  if(ya==1||ya%2==0)
  {
      if(xa!=0)
        printf("-1");
      else
        printf("%d",num);
       return 0;
  }
  else
 {
    if(xa>=2||xa<=-2||xa==0)
      {
         printf("-1");
         return 0;
      }
      else
      {
         if(xa>0)
            num++;
          printf("%d",num);
      }
      return 0;
 }
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
	float a,x,y;
	scanf("%f%f%f",&a,&x,&y);
	if(y <= 0 )
	{
		printf("-1\n");
		exit(1);
	}
	if((int)y %(int)a == 0 )
	{
		printf("-1\n");
		exit(1);
	}
	if(y < a)
	{
		printf("1\n");
		exit(1);

	}
//	printf("etfsgtsr\n");

	int num,one;

	num = y /a;
	if (num % 2 != 0)
		one = 1 ;
	else
		one = 0;

//	printf("num = %d\n",num);
//	printf("one = %d\n",one);
	if(one == 1)
	{
		if(x <= -a/2 || x >= a/2 )
		{
			printf("-1\n");
			exit(1);
		}
	}
	if(one == 0)
	{
		if(x <= -a || x >= a || x == 0 )
		{
			printf("-1\n");
			exit(1);
		}
	}

	int count = 1;

	count = count + ((2 * (num/2)) + num  - num/2);
	if(one == 1)
		printf("%d\n",count);
	else
	{
		if(x < 0)
		{
			printf("%d\n",count-1);
		}
		else if(x > 0)
			printf("%d\n",count);
		else
			printf("-1\n");
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d"&a,&b,&c);
    int k;
    if(a<b) {k=a;a=b;b=k;}
    if(b<c) {k=b;b=c;c=k;}
    if(a<b) {k=a;a=b;b=k;}
    if(c<=3||(a==2&&b==4&&c==4) printf("YES\n");
    else printf("NO\n");
}


#include <stdio.h>

int main() {
int i=0, count=0;
char word[100];

scanf("%s",word);

while(word[i] != '\0') {
    if(word[i] >= 'a' && word[i] <= 'z') {
        count++;
    }
}
i=0;
if(count == 0 || count == 1){
    while(word[i] != '\0'){
        if(word[i] >= 'a' && word[i] <= 'z'){
            printf("%c",word[i++]-32);
        }
        else{
            printf("%c",word[i++]+32);
        }
    }
}
else{
    while(word[i] != '\0'){
        printf("%c",word[i++]);
    }
}

return 0;
}


#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d",&n);
    int max=1,tmp=0;
    int i,j;
    for(i=1;i<=n-1;i++){

        for(j=1;j<=n-i;j++){
            if(n-i>=n-j) tmp=n+i;
            else tmp=n+j;
            if(max<tmp) max=tmp;

        }

    }
    printf("%d",max);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{

    char a[100];

    int i,n,s;
    char months0[]="January";
    char months1[]="February";
    char months2[]="March";
    char months3[]="April";
    char months4[]="May";
    char months5[]="June";
    char months6[]="July";
    char months7[]="August";
    char months8[]="September";
    char months9[]="October";
    char months10[]="November";
    char months11[]="December";

    while(scanf("%s",a))
    {
        scanf("%d",&n);
        s=0;
        if(strcmp(a,months0) == 0)
        {
           // printf("hello1\n");
            s = (1 + n) % 12;
        }
        else if(strcmp(a, months1) == 0)
        {
            //printf("hello2\n");
            s = (2 + n) % 12;
        }
        else if(strcmp(a, months2) == 0)
        {
            //printf("hello3\n");
            s= (3 + n) % 12;
        }
        else if(strcmp(a, months3) == 0)
        {
            //printf("hello4\n");
           s = (4 + n) % 12;
        }
        else if(strcmp(a, months4) == 0)
        {
            //printf("hello5\n");
            s = (5 + n) % 12;
        }
        else if(strcmp(a, months5) == 0)
        {
            //printf("hello6\n");
            s = (6 + n) % 12;
        }
        else if(strcmp(a, months6) == 0)
        {
            //printf("hello7\n");
            s= (7 + n) % 12;
        }
        else if(strcmp(a, months7) == 0)
        {
            //printf("hello8\n");
            s = (8 + n) % 12;
        }
        else if(strcmp(a, months8) == 0)
        {
            //printf("hello9\n");
            s= (9 + n) % 12;
        }
        else if(strcmp(a, months9) == 0)
        {
            //printf("hello10\n");
            s = (10 + n) % 12;
        }
        else if(strcmp(a, months10) == 0)
        {
            //printf("hello11\n");
           s = (11 + n) % 12;
        }
        else if(strcmp(a, months11) == 0)
        {
            //printf("hello12\n");
            s = (12 + n) % 12;
        }
        ///printf("%d\n",s);
        if(s == 1)
        {
            printf("%s\n", months0);
        }
        else if(s == 2)
        {
            printf("%s\n",months1);
        }
        else if(s == 3)
        {
            printf("%s\n", months2);
        }
        else if(s== 4)
        {
            printf("%s\n", months3);
        }
        else if(s == 5)
        {
            printf("%s\n", months4);
        }
        else if(s == 6)
        {
            printf("%s\n", months5);
        }
        else if(s == 7)
        {
            printf("%s\n", months6);
        }
        else if(s == 8)
        {
            printf("%s\n", months7);
        }
        else if(s == 9)
        {
            printf("%s\n", months8);
        }
        else if(s == 10)
        {
            printf("%s\n", months9);
        }
        else if(s == 11)
        {
            printf("%s\n", months10);
        }
        else if(s == 0)
        {
            printf("%s\n", months11);
        }
    }

    return 0;
}


#include<stdio.h>

int main()
{
  int a,b;
  scanf("%d %d",&a,&b);
  if(a==2 && b==3)
  {
       printf("<\n");
       return 0;
  }
  if(a==2 && b==4)
  {
       printf("=\n");
       return 0;
  }
  if(a==3 && b==)
  {
       printf(">\n");
       return 0;
  }
  if(a==4 && b==2)
  {
       printf("=\n");
       return 0;
  }

  if(a>b)
     printf("<\n");
  if(a<b)
     printf(">\n");
  if(a==b)
     printf("=\n");
  return 0;
}


#include<stdio.h>

int main()
{
 long long int n,a,b,c,d,i,p[3][3],j,sum,x,y,z,ans=0;

 scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);

 for(i=1;i<=n;i++)
 {
   for(j=1;j<=n;j++)
   {
     sum=a+b+i+j;
     x=sum-(b+i+d);
     y=sum-(a+i+c);
     z=sum-(c+i+d);
     if(x>=1&&x<=n&&y>=1&&y<=n&&z>=1&&z<=n) ans++;
   }

 }

 printf("%lld\n",ans);

return 0;
}


#include<stdio.h>

int absl(int x){
	if (x<0) return -x;
	else return x;
}

int main(){
	int st[100];
	int n,i,j,max,count,t;
	scanf("%d",&n);
	for (i=0;i<n;i++){
		scanf("%d",&st[i]);
	}
	scanf("%d",&t);
	max=1;
	for (i=0;i<n;i++){
		count=1;
		for (j=i+1;j<n;j++){
			if (absl(st[i]-st[j])<=t) count++;
		}
		if (max<count) max=count;
	}
	printf("%d\n",max);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b)
{
return *(int *)a-*(int *)b;
}
int main()
{
	int n,time,t[100],d[5000];
	int i,j,k=0;
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<n;i++)
		scanf("%d",&t[i]);
		scanf("%d",&time);
		qsort(t,i,sizeof(t[0]),cmp);
		for(j=i-1;j>=0;j--)
		{
			for(i=0;i<=j;i++)
			{
				if((t[j]-t[i])<=time)
				d[k++]=j-i+1;
			}
		}
		qsort(d,k,sizeof(d[0]),cmp);
		printf("%d\n",d[k-1]);
	}
	return 0;
}


#include <stdio.h>
#include <limits.h>
int c[30];
long long cost[30],dp[30];
long long min(long long a,long long b){return (a<b)?a:b;}
int main()
{
    int n,L,i,j;
    scanf("%d%d",&n,&L);
    for(i=0;i<n;i++) scanf("%d",&c[i]);
    for(i=0;i<30;i++)
    {
        cost[i]=LLONG_MAX;
        for(j=0;j<n && j<=i;j++) cost[i]=min(cost[i],c[j]*(1LL<<(i-j)));
    }
    for(i=0;i<30;i++)
    {
        int bit=L&(1<<i);
        if(i==0)
        {
            dp[i]=0;
            if(bit) dp[i]=cost[i];
        }
        else
        {
            if(bit) dp[i]=cost[i]+dp[i-1];
            else dp[i]=min(cost[i],dp[i-1]);
        }
    }
    printf("%lld\n",dp[29]);
    return 0;
}


#include<stdio.h>
void quicksort(float number[],long long int first,long long int last,float a[],float c[]){
   long long int i, j, pivot;
   float temp;

   if(first<last){
      pivot=first;
      i=first;
      j=last;

      while(i<j){
         while(number[i]<=number[pivot]&&i<last)
            i++;
         while(number[j]>number[pivot])
            j--;
         if(i<j){
            temp=number[i];
            number[i]=number[j];
            number[j]=temp;
			temp=a[i];
            a[i]=a[j];
            a[j]=temp;
			temp=c[i];
            c[i]=c[j];
            c[j]=temp;
         }
      }

      temp=number[pivot];
      number[pivot]=number[j];
      number[j]=temp;
	  temp=a[pivot];
      a[pivot]=a[j];
      a[j]=temp;
	  temp=c[pivot];
      c[pivot]=c[j];
      c[j]=temp;
      quicksort(number,first,j-1,a,c);
      quicksort(number,j+1,last,a,c);

   }
}
float power(long long int a,long long int b){
	int i,p=1;
	for(i=0;i<b;i++)
		p=p*a;
	return p;
}
int main(){
	long long int n,i,l,s=0,min;
	scanf("%lld %lld",&n,&l);
	float c[n],a[n],d[n];
	for(i=0;i<n;i++){
		scanf("%f",&c[i]);
		a[i]=power(2,i);
		d[i]=c[i]/a[i];
	}
	quicksort(d,0,n-1,a,c);
	min= (l/((long long int)a[0]) + 1)*((long long int)c[0]);
	for(i=0;l!=0;i++){
		if(min> s + (l/((long long int)a[i]) + 1)*((long long int)c[i]))
			min= s+(l/((long long int)a[i]) + 1)*((long long int)c[i]);
		s=s+(l/((long long int)a[i]))*((long long int)c[i]);
		l=l%((long long int)a[i]);
	}
	if(min>s)
		printf("%lld",s);
	else
		printf("%lld",min);

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int64_t i64;
typedef int32_t i32;

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

const i32 mod = 1000000007;

i32 inv (i32 a) {
  i32 t = 1;
  while (a > 1) {
    t = (i64) t * (mod - mod / a) % mod;
    a = mod % a;
  }
  return t;
}

void run (void) {
  const i32 n = read_int();
  i32 *factor = (i32 *) calloc (n + 1, sizeof (i32));
  for (i32 i = 1; i <= n; ++i) {
    factor[i] = i;
  }
  for (i32 i = 2; i * i <= n; ++i) {
    if (factor[i] < i) continue;
    for (i32 j = i * i; j <= n; j += i) {
      factor[j] = i;
    }
  }
  i32 *dp = (i32 *) calloc (n + 1, sizeof (i32));
  dp[1] = 0;
  for (i32 i = 2; i <= n; ++i) {
    i32 f[64];
    f[0] = 1;
    i32 len = 1;
    i32 t = i;
    while (t > 1) {
      i32 p = factor[t];
      while (t % p == 0) {
	t /= p;
      }
      for (i32 j = 0; j < len; ++j) {
	f[j + len] = f[j] * p;
      }
      len *= 2;
    }
    if (f[len - 1] != i) {
      dp[i] = dp[f[len - 1]];
      continue;
    }
    i32 prob[64];
    for (i32 j = 0; j < len; ++j) {
      prob[j] = (i64) (n / f[j]) * inv(n) % mod;
    }
    for (i32 j = len - 1; j >= 0; --j) {
      for (i32 k = j - 1; k >= 0; --k) {
	if ((j & k) == k) {
	  prob[k] = (prob[k] - prob[j] + mod) % mod;
	}
      }
    }
    i32 local = 1;
    for (i32 j = 0; j < len - 1; ++j) {
      local = (local + (i64) prob[j] * dp[f[j]]) % mod;
    }
    dp[i] = local * inv((1 - prob[len - 1] + mod) % mod) % mod;
  }
  i32 ans = 1;
  for (i32 i = 1; i <= n; ++i) {
    ans = (ans + (i64)dp[i] * inv(n)) % mod;
  }
  print_int(ans);
  puts("");
}

int main (void) {
  run ();
  return 0;
}


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
	<FileVersion major="1" minor="6" />
	<Project>
		<Option title="kth didgit of infinite sequence shorter range" />
		<Option pch_mode="2" />
		<Option compiler="gcc" />
		<Build>
			<Target title="Debug">
				<Option output="bin/Debug/kth didgit of infinite sequence shorter range" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Debug/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-g" />
				</Compiler>
			</Target>
			<Target title="Release">
				<Option output="bin/Release/kth didgit of infinite sequence shorter range" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Release/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-O2" />
				</Compiler>
				<Linker>
					<Add option="-s" />
				</Linker>
			</Target>
		</Build>
		<Compiler>
			<Add option="-Wall" />
		</Compiler>
		<Unit filename="main.c">
			<Option compilerVar="CC" />
		</Unit>
		<Extensions>
			<code_completion />
			<envvars />
			<debugger />
		</Extensions>
	</Project>
</CodeBlocks_project_file>


#include<stdio.h>
#include<string.h>
int main()
{
    char s[200000], s1[7];
    int n, i;
    scanf("%d", &n);
    for (i=1; i<100001; i++) {
        sprintf(s1, "%d", i);
        strcat(s, s1);
    }
    printf("%c\n", s[n-1]);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
int comp (const void * elem1, const void * elem2)
{
    int f = *((int*)elem1);
    int s = *((int*)elem2);
    if (f > s) return  1;
    if (f < s) return -1;
    return 0;
}
int main()
{
    int n,d;
    scanf("%d %d",&n,&d);
    int points[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&points[i]);
    }
    qsort (points, sizeof(points)/sizeof(*points), sizeof(*points), comp);
    int c1=0,c2=0;

    for(int i=n-1;i>0;i--)
    {
        if(points[i]-points[0]>d)
            c1++;
        else
            break;
    }
    for(int i=0;i<n-1;i++)
    {
        if(points[n-1]-points[i]>d)
            c2++;
        else
            break;
    }if(c1>c2)
    printf("%d",c2);
    else
        printf(%d,c1);

    return 0;
}


#include <stdio.h>

int main(int argc, char* argv[])
{
  int day, berry;
  scanf("%d %d",&day, &berry);
  while(day!=0&&berry!=0)
    {
      int i, week[day], max = 0;
      for (i=0; i<day; i++)
	scanf("%d",&week[i]);

      for (i=0; i<day-1; i++)
	max= ((week[i]-week[i+1]-berry) > max)? (week[i]-week[i+1]-berry) : max;

  printf("%d", max);

      scanf("%d%d \n",&day, &berry);
    }
}


#include <stdio.h>

int main(){
    int n,indexOne=1,indexTwo=1,indexThree=0,temp;
    scanf("%d",&n);
    int gameArr[n+1],inp;
    for(int i=0;i<n;i++){
        scanf("%d",&inp);
        gameArr[i]=inp;
    }
    if(gameArr[0]==3){
        printf("NO");
        return 0;
    }else if(n>=2){
        if((gameArr[0]==1 && gameArr[1]==2)||(gameArr[0]==2 && gameArr[1]==1)){
        printf("NO");
        return 0;
        }
        for(int i = 0; i < n-2 ; i++){
            if(gameArr[i]==gameArr[i+2] && gameArr[i]!=gameArr[i+1]){
                printf("NO");
                return 3;
            }
        }
    }
    temp=indexOne;
    for(int i = 0; i<n;i++){
        if(gameArr[i]==1){
            temp = indexOne;
            indexOne++;
            indexOne=indexOne%2;
        }
        if(gameArr[i]==1 && i%2==temp){
            printf("NO");
            return 0;
        }
    }
    temp=indexTwo;
    for(int i = 0; i<n;i++){
        if(gameArr[i]==2){
            temp=indexTwo;
            indexTwo++;
            indexTwo=indexTwo%2;
        }
        if(gameArr[i]==2 && i%2==temp){
            printf("NO");
            return 0;
        }
    }
    temp = indexThree;
    for(int i = 0; i<n;i++){
        if(gameArr[i]==3){
            temp = indexThree;
            indexThree++;
            indexThree = indexThree%2;
        }
        if(gameArr[i]==3 && i%2==temp){
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    return 0;
}


#include <stdio.h>
#include <math.h>
 int main(){

int n,m,k,i,min;
scanf ("%d%d%d",&n,&m,&k);
  min=n-1;
int *t=malloc (sizeof(int)*n);
for (i=0; i<n;i++){
    scanf ("%d",t+i);

    if (t[i]!=0 &&t[i]=<k && abs (m-i-1) < min ){
            min =abs(m-i-1);

    }
}
  printf ("%d",min*10);

}


#include<stdio.h>
#include <stdlib.h>
int min(int num1, int num2);

int main()
{

    int n = 0;
    int x1 = 0;
    int y1 = 0;
    int x2 = 0;
    int y2 = 0;

    scanf("%d %d %d %d %d", &n, &x1, &y1 ,&x2 , &y2);
    if(abs(x2-x1)!=n && abs(y2-y1)!=n){
    int distance = abs(x2-x1)+abs(y2-y1);
    printf("%d",distance);}
    else if( abs(x2-x1)==n) {
      int distance =min(y1+y2,n-y1+n-y2)+n;
      printf("%d",distance);
    }
    else if( abs(y2-y1)==n) {
        int distance = min(x1+x2,n-x1+n-x2)+n;
      printf("%d",distance);
    }


#include<stdio.h>
main()
{
    long int n,m,a,b,p,q,cntd=0,cntb=0,i,j,k,d,b1;
    scanf("%ld%ld%ld%ld",&n,&m,&a,&b);
    p=n;q=n;
    while(1)
    {
        if(q%m!=0)
        {
            q=q-1;cntd++;
        }
        else break;
    }
    while(1)
    {
        if(p%m!=0)
        {
            p=p+1;cntb++;
        }
        else break;
    }
    b1=cntb*a;d=cntd*b;
    if(b1>d)printf("%ld\n",d);
    else printf("%ld\n",b1);
    return 0;

}


#include<stdio.h>
int main()
{
    int n,m;
    scanf("%d",&n);
    scanf("%d",&m);
    n>m;
        if(n==m)
        {
            printf("%d",0);
        }
        else if (m==0||m==1)
        {
            printf("%d",1);
        }
        else if((n-m)>=m)
        {
            printf("%d",m);
        }
        else if((n-m)<=m) {
                printf ("%d",n-m);
             }
    return 0;


#include<iostream>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	if(m==0){
		cout<<"1"<<endl;
		return 0;
	}

	else if(m==n){
		cout<<"0"<<endl;
		return 0;
	}

	int num,flag=0;
	if((n&1)!=0)
		flag=1;
	int t=n/2;
	if(m<=t)
		cout<<m<<endl;
	else{
		if(flag==0)
			cout<<t-(m-t)<<endl;
		else
			cout<<t-(m-t-1)<<endl;
	}
	return 0;
}


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

int main()
{
    long times,n,value,lvalue,ans,g,maxg=0,v[46],i,j,k;
    scanf("%ld%ld%ld",&times,&n,&value);
    for (i=1;i<=n;i++)
        scanf("%ld",&v[i]);
    ans=0;
    for (i=1;i<=n;i++)
        ans+=v[i];
    for (i=0;i<=times;i++)
        if (value-ans*i>=0)
        {
            g=(n+1)*i;
            lvalue=value-ans*i;
            for (j=1;j<n;j++)//can't solve any problem more
                for (k=1;k<=times-i;k++)
                    if (lvalue-v[j]>=0)
                    {
                        g++;
                        lvalue-=v[j];
                    }
                    else
                        break;
            if (g>maxg)
                maxg=g;
        }
        else
            break;
    printf("%ld\n",maxg);
    return 0;
}


// write in C...
#include <stdio.h>

#ifdef DEBUG
#define D(x...) fprintf(stderr, x)
#else
#define D(x...)
#endif

#define MOD 1000000009

int n, w, b;
int c[4005][4005];

int p(int n, int k) {
    if (k > n || k < 1) return 0;
    else return c[n-1][k-1];
}

int main() {
    int i, j;

    scanf("%d %d %d", &n, &w, &b);

    for (i = 0; i < 4005; i++) c[i][0] = 1;
    for (i = 1; i < 4005; i++)
        for (j = 1; j <= i; j++)
            c[i][j] = (c[i-1][j-1] + c[i-1][j]) % MOD;

    long long res = 0;

    for (i = 0; i <= n; i++) {
        res = (res + (long long)p(b, i) * (long long)p(w, n-i) * (long long)(n-i-1)) % MOD;
    }

    for (i = 1; i <= w; i++) res = (res * i) % MOD;
    for (i = 1; i <= b; i++) res = (res * i) % MOD;

    printf("%d\n", (int)res);

    return 0;
}


#include<stdio.h>

int ans[3] = {(0)};
void convert(char in[], int out[]){
 int i = 0;
 while(in[i]){
 	if (in[i] == 'R')
	 	out[0] += 1;
	else if (in[i] == 'G')
		out[1] += 1;
	else
 		out[2] += 1;
 	i++;

	}
 i = 0;
 while(i < 3){
 	if (out[i] > 1)
 		out[i] = 2;
 }
}

void play(int r, int g, int b){
	if(r + b + g == 1){
		if(r == 1)
			ans[0] = 1;
		else  if(g == 1)
			ans[1] = 1;
		else
			ans[2] = 1;
	}
	else{
		if(r >= 2)
			play(r - 1, g, b);
		if(g >= 2)
			play(r , g - 1, b);
		if(b >= 2)
			play(r , g, b - 1);
		if(r >= 1 && g >= 1)
			play(r - 1 , g -1, b + 1);
		if(r >= 1 && b >= 1)
			play(r - 1 , g + 1, b - 1);
		if(g >= 1 && b >= 1)
			play(r + 1 , g - 1, b - 1);
	}
}

void output(){

	if (ans[2])
		printf("B");
	if (ans[1])
		printf("G");
	if (ans[0])
		printf("R");

}
int main(){
	char in[201];
	int n, out[3] = {(0)};
	scanf("%d", &n);
	scanf("%s", &in);
	convert(in, out);

	play(out[0], out[1], out[2]);

	output();
	return 0;
}


#include<stdio.h>
#define N 201
//RGB
//RG
//RB
//GB
int have_R;
int have_G;
int have_B;
void count(int R,int G,int B){
	if(R+G+B==1){
		if(R==1){
			have_R=1;
		}
		if(G==1){
			have_G=1;
		}
		if(B==1){
			have_B=1;
		}

		return;
	}
	if(R>1){
		count(R-1,G,B);
	}
	if(G>1){
		count(R,G-1,B);
	}
	if(B>1){
		count(R,G,B-1);
	}
	if(R>0 && G>0){
		count(R-1,G-1,B+1);
	}
	if(R>0 && B>0){
		count(R-1,G+1,B-1);
	}
	if(G>0 && B>0){
		count(R+1,G-1,B-1);
	}
}
int main() {
	int n;
	scanf("%d",&n);
	char s[N];
	scanf("%s",s);
	int i;
	int Rs=0;
	int Bs=0;
	int Gs=0;
	for(i=0;i<n;i++){
		if(s[i]=='R'){
			Rs++;
		}else if(s[i]=='G'){
			Gs++;
		}else{
			Bs++;
		}
	}
	have_R=0;
	have_G=0;
	have_B=0;
	count(Rs,Gs,Bs);
	if(have_B)printf("B");
	if(have_G)printf("G");
	if(have_R)printf("R");
	printf("\n");

	return 0;
}


#include <stdio.h>
#include <string.h>
int main(){
	int a,b,s;
	scanf("%d%d%d",&a,&b,&s);
	if(a+b>s||(s%(a+b))==1){
		printf("NO");
	}
	else{
		printf("YES");
	}
}


#include <stdio.h>

int main()
{
	int n;
	scanf("%d",&n);
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",a[i]);
	}
	int b[n];
	for (int i = 0; i < n; ++i)
	{
		b[i]=-1;
	}
	int k=0;
	for (int i = n-1; i >=0 ; i--)
	{
		int flag=0;
		for (int j = 0; j < n; ++j)
		{
			if (b[j]==a[i])
			{
				flag=1;
				break;
			}
		}
		if (flag!=1)
		{
			b[k++]=a[i];
		}
	}
	int c;
	for (c = 0; b[c]!=-1 ; ++c);
		printf("%d\n",c);
	for (int i = c-1; i>=0; i--)
	{
		printf("%d ",b[i]);
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>

int main()
{
    int necesarios, cantinicial = 1, a = 1, i;
    scanf("%i", &necesarios);
    while(cantinicial != necesarios && cantinicial != necesarios - 1)
    {
        cantinicial = cantinicial * 2;
        if(cantinicial > necesarios)
        {
            cantinicial = 0;
            for(i = 0; i <= a; i++)
            {
                cantinicial++;
                cantinicial = cantinicial * 2;
            }
            a++;
        }
    }
    if(cantinicial == necesarios - 1){printf("%i", a + 1);}
    else{printf("%i", a);}
return 0;
}


#include<stdio.h>
int main()
{
    int a[7],n,i;
    scanf("%d",&n);
    for(i=0;i<7;i++)
        scanf("%d",&a[i]);
    while(n>=0)
    {
        for(i=0;i<n;i++)
        {
            if(n>=0)
                n=n-a[i];
            else
                break;
        }
    }
    printf("%d",i);
    return 0;

}


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

int main(){
    long long z,k;
    scanf("%lli",&z);
    for(k=0;k<z;k++){
    long long n,k,d;
    scanf("%lli %lli %lli",&n,&k,&d);
    long long i,j;
    long long *tab;

    tab=(int*)malloc(sizeof(int)*n);

    for(i=0;i<n;i++)
        scanf("%lli",&tab[i]);
    long long min=d;

    for(j=0;j<n-d+1;j++){
        long long *t;
        t=(int*)malloc(sizeof(int)*d);
        long long count=0;
        for(i=j;i<d+j;i++){
            long long x=0,verif=0;
            for(x=0;x<count;x++)
            if(tab[i]==t[x])
                verif=1;

            if(verif==0){
                t[count++]=tab[i];
            }
        }
        if(count<min)
            min=count;
    }
    printf("%lli\n",min);
    }
}


#include <stdio.h>

double Sumofdigits( double x){

	double c;
	c= x - ( (x/10)*10 );

	if(x <= 9 && x>=0 ){
		return x;
		}
	else {
		return Sumofdigits((x - c )/10) + c;
		}
}

int main()
{
	int k, c=0;
	double i=19;

	scanf("%d" ,&k);
	while ( c != k){

   if (10 == Sumofdigits(i)){
   	c++;
   	}
   i=i+9;
   }

	printf("%.0lf" , (i-1) );

	return 0;
}


#include<stdio.h>
int main()
{
	int n,m,k,i,j,count,temp,o=0;
	scanf("%d%d%d",&n,&m,&k);
	int a[n];
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(i=0;i<n-1;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(a[i]>a[j])
			{
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
		}
	}
	m=m-k;
	temp=0;
	count=0;
	o=0;
	for(i=n-1;i>=0;i--)
	{
		if(temp<m)
		{
			temp=temp+a[i]-1;
			o++;
		}
		else if(temp>=m)
		{
			printf("%d",o);
			count=1;
			break;
		}
	}
	if(count==0)
	printf("-1");
}#include<stdio.h>
int main()
{
	int n,m,k,i,j,count,temp,o=0;
	scanf("%d%d%d",&n,&m,&k);
	int a[n];
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(i=0;i<n-1;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(a[i]>a[j])
			{
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
		}
	}
	m=m-k;
	temp=0;
	count=0;
	o=0;
	for(i=n-1;i>=0;i--)
	{
		if(temp<m)
		{
			temp=temp+a[i]-1;
			o++;
		}
		else if(temp>=m)
		{
			printf("%d",o);
			count=1;
			break;
		}
	}
	if(count==0)
	printf("-1");
}


#include<stdio.h>
#include<string.h>
#include<stdbool.h>
bool isPalin(char str[]) {
    int o=strlen(str);
    for(int i=0;i<o/2;i++) {
        if(str[i]!=str[o-i-1]) {
            return false;
        }
    }
    return true;
}
int mxLength(char str[]) {
    int l=strlen(str);
    int p=str[0];
    int i=1;
    for(i=1;i<l;i++)
        if(str[i]!=p)
            break;
    if(i==l) {
        return 0;
    }
    if(isPalin(str)) {
        return l-1;
    }
   return l;
}
int main() {
    char str[10];
    int flag=0;
    scanf("%s",str);
    int n=mxLength(str);
    printf("%d",n);
}


#include <stdio.h>
#include <math.h>
#include <string.h>
int palindrome(char str[]){
    int l = 0;
    int len = strlen(str)-1;
    while(len > l){
        if(str[l++] != str[len--])
            return 1;
    }
    for(int i = 1;i<strlen(str);i++){
        if(str[i] != str[0])
        return 2;
    }
    return 0;
}
int main()
{
    char str[10];
    scanf("%s", str);
    int k = palindrome(str);
    if(k == 1)
        printf("%d", strlen(str));
    else if( k == 0)
        printf("0");
    else if(k == 2)
        printf("%d", strlen(str) - 1);
    return 0;
}


#include <stdio.h>
#include <limits.h>

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for((i) = 0; (i) < (n); (i)++)
#define REP1(i, n) for((i) = 1; (i) <= (n); (i)++)

#define SIZE 1000002

static int s[SIZE], p[SIZE], np, min;

static void sieve(void)
{
    int i, j;

    for (i = 2; i < SIZE; i++) {
        if (s[i] == 0) {
            p[np++] = i;

            for (j = 2; i * j < SIZE; j++) {
                s[i * j] = 1;
            }
        }
    }
}

static void solve(int x, int l)
{
    int i, d, lf = -1;

    if (x < min) {
        min = x;
    }

    if (l == 0) {
        return;
    }

    for (i = 0; p[i] <= x / 2; i++) {
        if (x % p[i] == 0) {
            lf = p[i];
        }
    }

    if (lf == -1) {
        return;
    }

    for (d = lf * (x / lf - 1) + 1; d < lf * (x / lf); d++) {
        solve(d, l - 1);
    }
}

int main(void)
{
    int x2;

    sieve();
    min = INT_MAX;

    scanf("%d", &x2);
    solve(x2, 2);
    printf("%d", min);

    return 0;
}


#include <stdio.h>

int good(int i, int p) {
	int k;

	for (k = 0; k < 25; k++) {
		i = (i * 96 + 42) % 475;
		if (i + 26 == p)
			return 1;
	}
	return 0;
}

int main() {
	int p, y, x, i, a, b, min, res;

	scanf("%d%d%d", &p, &x, &y);
	a = y / 50;
	b = x / 50;
	min = 1000;
	for (i = a; i <= b + 475; i++) {
		res = i < b ? 0 : (i - b + 1) / 2;
		if (good(i % 475, p) && min > res)
			min = res;
	}
	printf("%d\n", min);
	return 0;
}


# include <stdio.h>
# include <string.h>

int solve(int s,int p)
{
	int k=(s/50)%475;
	for(int i=0;i<25;i++)
	{
		k=(k*96+42)%475;

		if(k+26==p)
		return 1;
	}
	return 0;
}
int main()
{
	int p,x,y;
	scanf("%d%d%d",&p,&x,&y);
	int i=x;
	int j=x;
	int r1,r2;
	//printf("%d",solve(7408,26));
	if(x%50==0&&y%50==0)
	{
		printf("0");
		return 0;
	}
	int cnt=0,k=0;
		while(i>0)
		{

			int c=solve(i,p);
			if(c==1)
			{
				printf("%d",cnt);
				return 0;
			}
			i+=50;

			if(k%2==0)
			cnt++;
				k++;
		}

}


#include<stdio.h>
int main()
{
		long long int n,k;
		scanf("%lld%lld",&n,&k);
		int i,j;
		int count=0;
		int t,flag=0;
		for(i=1;i*i<=n;i++)
		{
				if(n%i==0)
						count++;
				if(count==k)
				{
						flag=1;
						printf("%d\n",i);
						break;
				}
		}
		if((i-1)*(i-1)==n)
				j=i-2;
		else
				j=i-1;
		for(;j>0;j--)
		{
				t=n/j;
				if(n%t==0)
						count++;
				if(count==k)
				{
						if(flag==0)
						{
								flag=1;
								printf("%d\n",t);
								break;
						}
				}
		}
		if(flag==0)
				printf("-1\n");

		return 0;
}


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

int main()
{
    long long k,b,t,x=1;
    int l=0,n;
    scanf("%lld %lld %d %lld",&k,&b,&n,&t);
    while(x<t&&i<n)
    {
        x=k*x+b;
        l++;
    }
    if(x>t)
    {
        l--;
    }
    printf("%d",n-l);
    return 0;
}


#include <stdio.h>

int o[1000], u = 0;
int n, k, i, z, count = 0, divizori;

int pr (int z)
{
  divizori = 0;
        for(i = 0; i <= z; i++)
        if(z % i == 0) divizori ++;
        if(divizori == 2) return 1; else return 0;
}
int main()
{
    scanf("%d %d", &n, &k);
    for(z = 0; z <= n; z++)
    {
        if(pr(z) == 1)
        {
          o[u] = z; u++ ;
        }
    }
    for(i = 0; i< u - 1; i++)
    if(pr(o[i] + o[i + 1] + 1) == 1 && o[i] + o[i + 1] + 1 <= n)
    count ++;
    if(count >= k) printf("YES"); else printf("NO");

    return 0;
}


#include<stdio.h>
int main(){
int n,a,c;
scanf("%d",&n);
 while(n>0){
        scanf("%d",&a);
        if(a%7==0|| a%3==0) printf("YES\n");
         else if(a<7){
            if(a%3!=0) printf("NO");
        }
        else{
while(a>0){
 a-=7;
 if(a%3==0) break;
}
 if(a%3==0) printf("YES");
    else printf("NO\n");
n--;
}
 }
}


#include<stdio.h>
#include<stdbool.h>

int main(){
int T,n,i;scanf("%d\n",&T);
for(i=0,n= T ;i<n;++i)
    {
int X;
scanf("%d\n",&X);
bool found =false;
for(i=0;7*i<= X &&!found ;++i){
             found =((X -7*i)%3==0);
}
printf("%s\n", found ?"YES":"NO");
printf("NO");
}
return 0;
}


/*			                       ____COMPETITIVE CODING____                                                          */

//--Header Files--

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <time.h>

//--Macros--

#define N 200001
#define R 100000007
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

//--Structures--

//--Comparator Functions--

int comp(const void *a, const void *b)
{
	return (*(int *)a - *(int *)b);
}
int comp_desc(const void *a, const void *b)
{
	return (*(int *)b - *(int *)a);
}

//--Function Declarations--

// void qsort(array name, size of array, size of each element, comp);
// int* bsearch(address of search element, array name, size of array, size of each element, comp);
int rmdup(int [], int); // int rmDup(array, size of array);
int gcd(int, int); // int gcd(first number, second number);

//--Useful Variables--

int i = 0, j = 0, k = 0, flag = 1, count = 0, temp, pos = 0, test_case, mx = 0, mn = INT_MAX;
long long sum = 0, product = 1;

int main()
{
	//clock_t tStart = clock();
	int a, b, diff;
	scanf("%d %d", &a, &b);
	diff = abs(a - b);
	mn = MIN(a, b);
	mx = MAX(a, b);

	if(mn % diff == 0)
	{
		printf("0\n");
		return 0;
	}
	if(mn < diff)
	{
		for(i = mn; i <= diff / 2; i++)
		{
			if(diff % i == 0)
			{
				flag = 0;
				break;
			}
		}
		if(!flag)
		{
			printf("%d\n", i - mn);
			return 0;
		}
		else
		{
			printf("%d\n", diff - mn);
			return 0;
		}
	}
	else
	{
		printf("%d\n", diff - mn % diff);
		return 0;
	}

	//printf("%lf seconds.\n", (clock() - tStart)/CLOCKS_PER_SEC);
	return 0;
}

int rmdup(int a[], int n)
{
	if(n == 0 || n == 1)
		return n;
	int j = 0;
	for(i = 0; i < n - 1; i++)
	{
		if(a[i] != a[i+1])
		{
			a[j++] = a[i];
		}
	}
	a[j++] = a[n-1];
	return j;
}

int gcd(int x, int y)
{
	if(y == 0)
	{
		return x;
	}
	else
	{
		return gcd(y, x % y);
	}
}


#include<stdio.h>
int gcd(int a,int b){
	int t;
	while(b>0){
		t=a%b;
		a=b;
		b=t;
	}
	return a;
}
int main()
{
	long long a,b;
	scanf("%I64d %I64d",&a,&b);
	long long t;
	if(a>b){
		t=a;
		a=b;
		b=t;
	}
	t=b-a;
	long long k=0;
	long long k1;
	long long min=a*b/gcd(a,b);
	for(long long i=1;i*i<=t;i++){
		k1=i-b%i;
		if((a+k1)*(b+k1)<min*gcd(a+k1,b+k1)){
			min=(a+k1)*(b+k1)/gcd(a+k1,b+k1);
			k=k1;
		}
		k1=(t/i)-b%(t/i);
		if((a+k1)*(b+k1)<min*gcd(a+k1,b+k1)){
			min=(a+k1)*(b+k1)/gcd(a+k1,b+k1);
			k=k1;
		}
	}
	printf("%I64d\n",k);
	return 0;
}


#include<stdio.h>
#include<string.h>

int n;
int a[3];
char dp[300*300*300];
long long step = 0;

void calculate_result(int index, long long index1){
    if(index >= n){
        if(index1 == 0){
           dp[0] = 0;
           return;
        }
        int i, min = 300,j;
        long long index2 = index1;
        for(i=0;i<n;i++){
            min = (min > (index2 % 300) ) ? (index2 % 300) : min;
            index2 /= 300;
        }
        int win = 0;
        for(i=1;i<=min;i++){
            if(dp[index1 - i*step] == 0){
                win = 1;
                break;
            }
        }
        index2 = index1;
        long long pos = 1;
        if(win == 0){
            for(i=0;i<n;i++){
                int num = index2 % 300;
                for(j=1;j<=num;j++){
                    if(dp[index1 - pos*j] == 0){
                        win = 1;
                        break;
                    }
                }
                if( win == 1 )
                    break;
                index2 /= 300;
                pos *= 300;
            }
        }
        if(win == 1)
            dp[index1] = 1;
        return;
    }
    int i;
    for(i=0;i<=a[index];i++){
        calculate_result(index+1, index1*300 + i);
    }
}

int main(){
    scanf("%d", &n);
    int i;
    for(i=0;i<n;i++)
        scanf("%d", &a[i]);
    memset(dp, 0, sizeof(char)*300*300*300);
    for(i=0;i<n;i++)
        step = step*300 + 1;
    calculate_result(0,0);
    long long ans_index = 0;
    for(i=0;i<n;i++){
        ans_index = ans_index*300 + a[i];
    }
    if(dp[ans_index] == 1){
        printf("BitLGM\n");
    }
    else{
        printf("BitAryo\n");
    }
    return 0;
}


#include<stdio.h>
#define MOD 1000000007

int dar[252][252], k, n, fact[252];

int add(int a, int b){
  a += b;
  if(a >= MOD)a -= MOD;
  return a;
}

int mul(int a, int b){
  return (a*1ll*b)%MOD;
}
int powmod(int base, long long p){
  int toret = 1;
  while(p){
    if(p&1)toret = mul(toret, base);
    base = mul(base, base);
    p >>= 1;
  }
  return toret;
}

int inv(int x){
  return powmod(x, MOD - 2);
}
int ncr(int n, int r){
  return mul(mul(fact[n], inv(fact[r])), inv(fact[n - r]));
}

int dp(int r, int c){
  //  printf("dp(%d, %d)\n", r, c);
  if(dar[r][c] == -1){
    int toret = 0;
    if(r == 0){
      dar[r][c] = (c == 0);
      return dar[r][c];
    }

    int sat = n - c;
    int i;
    for(i = 0;i <= c;i++)if(i + sat){
      int f1 = powmod(k - 1, c - i);
      f1 = mul(f1, ncr(c, i));
      int f2 = powmod(k, sat);
      if(i == 0){
	f2 = add(f2, MOD - powmod(k - 1, sat));
      }
      toret = add(toret, mul(dp(r - 1, c - i), mul(f1, f2)));
    }
    dar[r][c] = toret;
  }
  return dar[r][c];
}

int main(){
  scanf("%d %d", &n, &k);
  int i,j;
  fact[0] = 1;
  for(i = 1;i < 252;i++)fact[i] = mul(fact[i - 1], i);
  for(i = 0;i <= n;i++)for(j = 0;j <= n;j++){
      dar[i][j] = -1;
    }
  printf("%d\n", dp(n, n));
  return 0;
}


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

#define N 2000000
#define MOD 1000000007

int maxp[N + 1];
int lcm[N + 1];
int p[200000];

int max(int x, int y) {
  return x > y ? x : y;
}

int cmp(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main(void) {
  for (int i = 0; i <= N; i++) {
    maxp[i] = i;
  }
  for (int i = 2; i <= N; i++) {
    if (maxp[i] == i) {
      for (int j = i * 2; j <= N; j += i) {
        maxp[j] = i;
      }
    }
  }

  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  qsort(p, n, sizeof(int), cmp);
  int one = 0;
  for (int i = 0; i < n; i++) {
    int x = p[i];
    if (lcm[x] == 0) {
      lcm[x] = 1;
      continue;
    }
    bool any = false;
    x--;
    while (x != 1) {
      int p = maxp[x];
      int e = 0;
      while (x % p == 0) {
        x /= p;
        e++;
      }
      if (lcm[p] < e) {
        lcm[p] = e;
        any = true;
      }
    }
    if (!any) {
      one = 1;
    }
  }
  long long ans = 1;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j < lcm[i]; j++) {
      ans *= i;
      ans %= MOD;
    }
  }
  ans += one;
  ans %= MOD;
  printf("%lld\n", ans);
  return 0;
}


#include<cstdio>
int main()
{
    int x;
    scanf("%d",&x);
    for(long r=1;r<x;r++)
    {
        for(long c=1;c<x;c++)
        {
        long mul=r*c;
        if(mul>=x)
        {
            mul=10*(mul/x)+(mul%x);
        }
        printf("%ld ",mul);
        }
        puts("");

        }
        return 0;
    }


#include<stdio.h>
int main()
{
    int x;
    scanf("%d",&x);
    for(long r=1;r<x;r++)
    {
        for(long c=1;c<x;c++)
        {
        long mul=r*c;
        if(mul>=x)
        {
            mul=10*(mul/x)+(mul%x);
        }
        printf("%ld",mul);
        }
        puts("");

        }
        return 0;
    }


#include <stdio.h>

char S[200], T[200];
int DP[200][200];
int X[1000], Y[1000];
int M, N;

int main()
{
	//FILE *input, *output;
	//input = fopen("suffix.in", "r");
	int i, j, k, b, d;
	char c;

	for(M=0; ; M++)
	{
		//fscanf(input, "%c", &c);
		scanf("%c", &c);
		if(c == '\n')
			break;
		S[M] = c;
		X[(char) c]++;
	}
	for(N=0; ; N++)
	{
		//fscanf(input, "%c", &c);
		scanf("%c", &c);
		if(c == '\n')
			break;
		T[N] = c;
		Y[(char) c]++;
	}

	if(M < N)
	{
		printf("need tree\n");
		return 0;
	}

	if(M == N)
	{
		for(i=0, b=0; i<1000; i++)
		{
			if(X[i] != Y[i])
				b = 1;
		}

		if(b == 0)
			printf("array\n");
		else
			printf("need tree\n");
		return 1;
	}

	for(i=0; i<N && i<M; i++)
	{
		for(j=0; j<N || j<M; j++)
		{
			if(T[i] != S[j])
				continue;
			if(i == 0)
			{
				DP[i][j] = 1;
				continue;
			}
			for(k=0; k<j; k++)
			{
				if(DP[i-1][k] == 1)
					DP[i][j] = 1;
			}
		}
	}

	if((N < M && DP[N-1][M-1] == 1))
	{
		printf("automaton\n");
		return 1;
	}

	for(i=0, d=0; i<1000; i++)
	{
		if(X[i] < Y[i])
			d = 1;
	}

	if(d == 0)
		printf("both\n");
	else
		printf("need tree\n");
	return 1;
}


#include<stdio.h>
int main()
{
long long int i,j,n=0,m=0,count=0;
scanf("%lld%lld",&n,&m);
for(i=1;i<=n; i++)
{
	for (j=1;j<=m; j++)
	{
	if ((i+j)%5==0)
            count++;
	}
}
printf("%lld",count);
}


#include <stdio.h>
#include <stdlib.h>
int main()
{

    int n;
    int i,j,nbr=6;

    for(i=0;i<5;i++)
    {
        for(j=0;j<5;j++)
        {
            scanf("%d",&n);
            if(n)
            {
                nbr=abs(i-2)+abs(j-2);
                i=5;
                break;

            }
        }

    }
    printf("%d\n",nbr);
    return 1;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main()
{
	long long int k,i,j,a,b,l,flag=0;
	scanf("%lld",&k);
	char arr[15] ="codeforces";
	// for(i=0;i<10;i++)
	// {
	// 	printf("%c-%lld\n",arr[i],i);
	// }
	a=1,b=2;
	while(1)
	{
		for(i=0;i<=10;i++)
		{
			if(int(pow(b,i)*pow(a,10-i))>=k)
			{
				flag=1;
				break;
			}
		}
		if(flag==1)
		{
			break;
		}
		a++;
		b++;
	}
	for(j=1;j<=i;j++)
	{
		for(l=1;l<=b;l++)
		{
			printf("%c",arr[j-1]);
		}
	}
	for(j=i+1;j<=10;j++)
	{
		for(l=1;l<=a;l++)
		{
			printf("%c",arr[j-1]);
		}
	}
	printf("\n");
}


#include<stdio.h>
int main(void)
{
	int k;
	scanf("%d", &k);
	if (k == 1)
	{
		printf("codeforces\n");
		return 0;
	}
	printf("codeforcee");
	if (k % 2 == 0)
	{
		k = k / 2;
		while (k--)
			printf("s");
	}
	else
	{
		k = (k + 1) / 2;
		while (k--)
			printf("s");
	}
	printf("\n");
	return 0;
}


#include<stdio.h>
int main(void)
{
	unsigned long long k; //k的个数是2的16次方
	unsigned long long asn;
	scanf_s("%llu", &k);
	char s[10] = "codeforces";
	char q[11]; // 储存codeforces每个字符的重复次数
	//每个字符至少要重复出现一次
	int ten = 0;
	for (int i = 0; i < 10; i++)
		q[i] = 1;
	while (1)
	{
		asn = 1;
		for (int i = 0; i < 10; i++)
			asn = asn * q[i];
		if (asn >= k)
			break;
		if (ten == 10)
			ten = 0;
		q[ten]++;
		ten++;
	}
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < q[i]; j++)
			printf("%c", s[i]);
	return 0;
}


#include<stdio.h>

int main()
{
    long long int n;
    scanf("%lld",&n);
    int a[10];
    for(int i=0;i<10;i++)
      a[i]=1;
    char substr[11]="codeforces";
    int k=1;
    long long int p=0;
    while(k<n)
    {
        k/a[p%10];
        a[p%10]++;
        k*=a[p%10];
        p++

    }
    for(int i=0;i<10;i++)
      for(int j=0;j<a[i];j++)
        printf("%c",substr[i]);
    return 0;
}


#include<stdio.h>
int main()
{
    long long k;
    scanf("%lld",&k);
    char c[10]="s";
    char s[15]="codeforces";
    k=k-1;
    printf("%s",s);
    while(k--)
    {
        printf("%c",'s');
    }
    printf("\n");
}


#include<stdio.h>
#include<string.h>
int main()
{
	long int x,y,m;
	scanf("%ld",&x);
	scanf("%ld",&y);
	scanf("%ld",&m);
	int count=0;

	if((x==0 && y<=0) || (y==0 && x<=0) || (x<=0 && y<=0)|| (x==0 && y==0))
	{
		printf("%d\n",-1);

	}
	else
	{
		if(x>y)
		{
			while(y<m)
			{
				y+=x;
				count++;
			}
		}
		else
		{
			while(x<m)
			{
				x+=y;
				count++;
			}
		}

	printf("%d\n",count);
}
}


#include<stdio.h>
#include<string.h>
int main()
{
	long long int x,y,m,cnt=0;
	scanf("%lld",&x);
	scanf("%lld",&y);
	scanf("%lld",&m);

	if(x>=m || y>=m)
	{
		printf("%d\n",0);
		return 0;
	}
	if(x<=0 && y<=0)
	{
		printf("%d\n",-1);
		return 0;
	}
	if(x>y)
	{
		long long int tmp = x;
		x=y;
		y=tmp;
	}
	if(x<0)
	{
		cnt += -x/y;
		x+=y * cnt
	}
	while(x<m && y<m)
	{
		if(x<y)
			x+=y;
		else
			y+=x;
	}
	printf("%d\n",cnt);
	return 0;
}