import java.io.BufferedReader;
import java.io.InputStreamReader;
public class TEMP1
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(br.readLine());
        for(int i=1;i<=t;i++)
        {
            String s=br.readLine();
            String ar[]=s.split(" ");
            double arr[]=new double[4];
            arr[0]=Double.parseDouble(ar[0]);
            arr[1]=Double.parseDouble(ar[1]);
            arr[2]=Double.parseDouble(ar[2]);
            arr[3]=Double.parseDouble(ar[3]);
			double max=Math.max(arr[0],(Math.max(arr[1],arr[2])));
			double min=Math.min(arr[0],(Math.min(arr[1],arr[2])));
		if((max-min)<arr[3])
		{
            double A=((arr[3]-(2*arr[0])+arr[1]+arr[2])/3);
            double B=((arr[3]-(2*arr[1])+arr[0]+arr[2])/3);
            double C=((arr[3]-(2*arr[2])+arr[0]+arr[1])/3);
            if((A-(int)A)!=0||(B-(int)B)!=0||(C-(int)C)!=0)
            System.out.println("NO");
            else
            System.out.println("YES");
        }
		else
		System.out.println("NO");

    }}


import java.io.BufferedReader;
import java.io.InputStreamReader;
public class TEMP1
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(br.readLine());
        for(int i=1;i<=t;i++)
        {
            String s=br.readLine();
            String ar[]=s.split(" ");
            double arr[]=new double[4];
            arr[0]=Double.parseDouble(ar[0]);
            arr[1]=Double.parseDouble(ar[1]);
            arr[2]=Double.parseDouble(ar[2]);
            arr[3]=Double.parseDouble(ar[3]);
			double max=Math.max(arr[0],(Math.max(arr[1],arr[2])));
			double min=Math.min(arr[0],(Math.min(arr[1],arr[2])));
		if((max-min))<arr[3])
		{
            double A=((arr[3]-(2*arr[0])+arr[1]+arr[2])/3);
            double B=((arr[3]-(2*arr[1])+arr[0]+arr[2])/3);
            double C=((arr[3]-(2*arr[2])+arr[0]+arr[1])/3);
			if(A<0||B<0||C<0)
			  System.out.println("NO");
			 else
			 {
              if((A-(int)A)0||(B-(int)B)0||(C-(int)C)!=0)
            System.out.println("NO");
            else
            System.out.println("YES");
        }}
		else
		System.out.println("NO");

    }}
}


import javax.management.DynamicMBean;
import javax.print.DocFlavor;
import javax.print.attribute.HashAttributeSet;
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.attribute.FileAttribute;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
import java.util.Arrays;
import java.util.concurrent.Callable;

public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
       int t=sc.nextInt();
       for(int i=0;i<t;i++ ){
           long a=sc.nextLong();
           long b=sc.nextLong();
           long c=sc.nextLong();
           long n=sc.nextLong();
           long sum=(long)(a+b+c+n);
           double div=(double)sum/(double)3;
           if(div==(int)Math.floor(div)){
               System.out.println("YES");
           }
           else{
               System.out.println("NO");
           }
       }
    }
}


import javax.management.DynamicMBean;
import javax.print.DocFlavor;
import javax.print.attribute.HashAttributeSet;
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.attribute.FileAttribute;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
import java.util.Arrays;
import java.util.concurrent.Callable;

public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
       int t=sc.nextInt();

       for(int i=0;i<t;i++ ){
           long[] a=new long[3];
           a[0]=sc.nextLong();
            a[1]=sc.nextLong();
           a[2]=sc.nextLong();
           long n=sc.nextLong();
           Arrays.sort(a);
           n-=a[2]-(a[1]);
           n-=a[2]-a[0];
           if(n<0){
               System.out.println("NO");
           }
           else {
               double div = (double) n / (double) 3;
               if (div == (int) div) {
                   System.out.println("YES");
               } else {
                   System.out.println("NO");
               }
           }
       }
    }
}


import javax.management.DynamicMBean;
import javax.print.DocFlavor;
import javax.print.attribute.HashAttributeSet;
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.attribute.FileAttribute;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
import java.util.Arrays;
import java.util.concurrent.Callable;

public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
       int t=sc.nextInt();
       for(int i=0;i<t;i++ ){
           long a=sc.nextLong();
           long b=sc.nextLong();
           long c=sc.nextLong();
           long n=sc.nextLong();
           long sum=(long)(a+b+c+n);
           double div=(double)sum/(double)3;
           if(div==(int)div){
               System.out.println("YES");
           }
           else{
               System.out.println("NO");
           }
       }
    }
}


import javax.management.DynamicMBean;
import javax.print.DocFlavor;
import javax.print.attribute.HashAttributeSet;
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.attribute.FileAttribute;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
import java.util.Arrays;
import java.util.concurrent.Callable;

public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
       int t=sc.nextInt();
       for(int i=0;i<t;i++ ){
           long a=sc.nextLong();
           long b=sc.nextLong();
           long c=sc.nextLong();
           long n=sc.nextLong();
           long sum=(long)(a+b+c+n);
//           double div=(double)sum/(double)3;
           if(sum%3==0){
               System.out.println("YES");
           }
           else{
               System.out.println("NO");
           }
       }
    }
}


import javax.management.DynamicMBean;
import javax.print.DocFlavor;
import javax.print.attribute.HashAttributeSet;
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.attribute.FileAttribute;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
import java.util.Arrays;
import java.util.concurrent.Callable;

public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
       int t=sc.nextInt();
       for(int i=0;i<t;i++ ){
           int a=sc.nextInt();
           int b=sc.nextInt();
           int c=sc.nextInt();
           int n=sc.nextInt();
           long sum=(long)a+b+c+n;
           double div=(double)sum/(double)3;
           if(div==Math.floor(div)){
               System.out.println("YES");
           }
           else{
               System.out.println("NO");
           }
       }
    }
}


import java.util.*;
public class Solution615 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner ob=new Scanner(System.in);
		int t=ob.nextInt();
		while(t-->0) {
			int a=ob.nextInt();
			int b=ob.nextInt();
			int c=ob.nextInt();
			int n=ob.nextInt();
			int max=Math.max(Math.max(a, b),c);
			int A=max-a;
			int B=max-b;
			int C=max-c;
			int remain=n-(A+B+C);
			//System.out.println(""+ a+"|"+ b+"|"+ c+"|"+ n+"|"+ max+"|"+ A+"|"+ B+"|"+C+"|"+remain);
			if(remain>0 && remain%3==0) {
				System.out.println("Yes");
			}else {
				System.out.println("NO");
			}
		}
	}

}


import java.util.*;
public class Solution615 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner ob=new Scanner(System.in);
		int t=ob.nextInt();
		int ar[]=new int[3];
		while(t-->0) {
			for (int i = 0; i < ar.length; i++) {
				ar[i]=ob.nextInt();
			}
			Arrays.sort(ar);
			int n=ob.nextInt();

			/*int i=0;
			int ar[i]=ob.nextInt();
			int a[1]=ob.nextInt();
			int a[2]=ob.nextInt();
			*/
			/*int max=Math.max(Math.max(a, b),c);
			int A=max-a;
			int B=max-b;
			int C=max-c;*/
			//int remain=n-(A+B+C);
			int remain=n-(2*ar[2]-ar[1]-ar[0]);
			//System.out.println(""+ a+"|"+ b+"|"+ c+"|"+ n+"|"+ max+"|"+ A+"|"+ B+"|"+C+"|"+remain);
			if(remain>0 && remain%3==0) {
				System.out.println("Yes");
			}else {
				System.out.println("NO");
			}
		}
	}

}


package Vitrual;
import java.util.*;
public class Solution615 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner ob=new Scanner(System.in);
		int t=ob.nextInt();
		while(t-->0) {
			int a=ob.nextInt();
			int b=ob.nextInt();
			int c=ob.nextInt();
			int n=ob.nextInt();
			int max=Math.max(Math.max(a, b),c);
			int A=max-a;
			int B=max-b;
			int C=max-c;
			int remain=n-(A+B+C);
			//System.out.println(""+ a+"|"+ b+"|"+ c+"|"+ n+"|"+ max+"|"+ A+"|"+ B+"|"+C+"|"+remain);
			if(remain>0 && remain%3==0) {
				System.out.println("Yes");
			}else {
				System.out.println("NO");
			}
		}
	}

}


import java.util.*;
public class Solution615 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner ob=new Scanner(System.in);
		int t=ob.nextInt();
		int ar[]=new int[3];
		while(t-->0) {
			for (int i = 0; i < ar.length; i++) {
				ar[i]=ob.nextInt();
			}
			Arrays.sort(ar);
			int n=ob.nextInt();

			/*int i=0;
			int ar[i]=ob.nextInt();
			int a[1]=ob.nextInt();
			int a[2]=ob.nextInt();
			*/
			/*int max=Math.max(Math.max(a, b),c);
			int A=max-a;
			int B=max-b;
			int C=max-c;*/
			//int remain=n-(A+B+C);
			int remain=n-(2*ar[2]-ar[1]-ar[0]);
			//System.out.println(""+ a+"|"+ b+"|"+ c+"|"+ n+"|"+ max+"|"+ A+"|"+ B+"|"+C+"|"+remain);
			if(remain<0||remain%3!=0) {
				System.out.println("NO");
			}else {
				System.out.println("YES");
			}
		}
	}

}


import java.util.*;
public class Solution615 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner ob=new Scanner(System.in);
		int t=ob.nextInt();
		while(t-->0) {
			int a=ob.nextInt();
			int b=ob.nextInt();
			int c=ob.nextInt();
			int n=ob.nextInt();
			int max=Math.max(Math.max(a, b),c);
			int A=max-a;
			int B=max-b;
			int C=max-c;
			//int remain=n-(A+B+C);
			int remain=n-(2*c-b-a);
			//System.out.println(""+ a+"|"+ b+"|"+ c+"|"+ n+"|"+ max+"|"+ A+"|"+ B+"|"+C+"|"+remain);
			if(remain>0 && remain%3==0) {
				System.out.println("Yes");
			}else {
				System.out.println("NO");
			}
		}
	}

}


import java.util.*;
import java.io.*;
 public class ab{
    public static void main(String args[])
    {int x=0,y=0;
        Scanner sc=new Scanner (System.in);
       int t=sc.nextInt();
        for(int i=0;i<t;i++)
        {
      int a=sc.nextInt();
      int b=sc.nextInt();
      int c=sc.nextInt();
      int n=sc.nextInt();
      if(a>b && a>c)
      {
          x=a-b;
          y=a-c;
      }
      else if(b>a && b>c)
      {
          x=b-a;
          y=b-c;
      }
      else{
          x=c-a;
          y=c-b;
      }n=n-(x+y);
      if(n%3==0)
      {
          System.out.println("Yes");
      }
      else{
          System.out.println("No");
      }
    }}
}


import java.util.*;
import java.io.*;
 public class ab{
    public static void main(String args[])
    {int x=0,y=0,l=0;
        Scanner sc=new Scanner (System.in);

      int a=sc.nextInt();
      int b=sc.nextInt();
      int c=sc.nextInt();
      int n=sc.nextInt();
      if(a>=b && a>=c)
      {
          x=a-b;
          y=a-c;
      }
      else if(b>=a && b>=c)
      {
          x=b-a;
          y=b-c;
      }
      else if(c>=a && c>=b){
          x=c-a;
          y=c-b;
      }l=n-(x+y);
      if((l+x+y)%3==0)
      {
          System.out.println("yes");
      }
      else{
          System.out.println("no");

    }}
}


import java.util.*;
import java.io.*;
 public class ab{
    public static void main(String args[])
    {int x=0,y=0;
        Scanner sc=new Scanner (System.in);
       int t=sc.nextInt();
        for(int i=0;i<t;i++)
        {
      int a=sc.nextInt();
      int b=sc.nextInt();
      int c=sc.nextInt();
      int n=sc.nextInt();
      if(n>0)
      {
      if(a>=b && a>=c)
      {
          x=a-b;
          y=a-c;
      }
      else if(b>=a && b>=c)
      {
          x=b-a;
          y=b-c;
      }
      else if(c>=a && c>=b){
          x=c-a;
          y=c-b;
      }n=n-(x+y);
      if(n%3==0)
      {
          System.out.println("YES");
      }
      else{
          System.out.println("NO");
      }}
      else{System.out.println("NO");
    }}}
}


import java.util.*;
import java.io.*;
 public class ab{
    public static void main(String args[])
    {int x=0,y=0;
        Scanner sc=new Scanner (System.in);
       int t=sc.nextInt();
        for(int i=0;i<t;i++)
        {
      int a=sc.nextInt();
      int b=sc.nextInt();
      int c=sc.nextInt();
      int n=sc.nextInt();
      if(a>=b && a>=c)
      {
          x=a-b;
          y=a-c;
      }
      else if(b>=a && b>=c)
      {
          x=b-a;
          y=b-c;
      }
      else if(c>=a && c>=b){
          x=c-a;
          y=c-b;
      }n=n-(x+y);
      if(n%3==0)
      {
          System.out.println("YES");
      }
      else{
          System.out.println("NO");
      }
    }}
}


import java.util.*;
import java.io.*;
 public class ab{
    public static void main(String args[])
    {int x=0,y=0;
        Scanner sc=new Scanner (System.in);
       int t=sc.nextInt();
        for(int i=0;i<t;i++)
        {
      int a=sc.nextInt();
      int b=sc.nextInt();
      int c=sc.nextInt();
      int n=sc.nextInt();
      if(n>0)
      {
      if(a>=b && a>=c)
      {
          x=a-b;
          y=a-c;
      }
      else if(b>=a && b>=c)
      {
          x=b-a;
          y=b-c;
      }
      else if(c>=a && c>=b){
          x=c-a;
          y=c-b;
      }n=n-(x+y);
      if(n%3==0)
      {
          System.out.println("YES");
      }
      else{
          System.out.println("NO");
      }}
      else {
          System.out.println("NO");
    }}}
}


import java.util.*;
import java.io.*;
 public class ab{
    public static void main(String args[])
    {int x=0,y=0,l=0;
        Scanner sc=new Scanner (System.in);
       int t=sc.nextInt();
        for(int i=0;i<t;i++)
        {
      int a=sc.nextInt();
      int b=sc.nextInt();
      int c=sc.nextInt();
      int n=sc.nextInt();
      if(n>0)
      {
      if(a>=b && a>=c)
      {
          x=a-b;
          y=a-c;
      }
      else if(b>=a && b>=c)
      {
          x=b-a;
          y=b-c;
      }
      else if(c>=a && c>=b){
          x=c-a;
          y=c-b;
      }n=n-x-y;if(n<0){
        System.out.println("NO");}else{
      if(n%3==0)
      {
          System.out.println("YES");
      }
      else{
          System.out.println("NO");

    }}}}
}}


import java.util.*;
import java.io.*;
 public class ab{
    public static void main(String args[])
    {int x=0,y=0;
        Scanner sc=new Scanner (System.in);
       int t=sc.nextInt();
        for(int i=0;i<t;i++)
        {
      int a=sc.nextInt();
      int b=sc.nextInt();
      int c=sc.nextInt();
      int n=sc.nextInt();
      if(n>0)
      {
      if(a>=b && a>=c)
      {
          x=a-b;
          y=a-c;
      }
      else if(b>=a && b>=c)
      {
          x=b-a;
          y=b-c;
      }
      else if(c>=a && c>=b){
          x=c-a;
          y=c-b;
      }n=n-(x+y);
      if(n%3==0)
      {
          System.out.println("YES");
      }
      else{
          System.out.println("NO");
      }}
      else {
          if(a==b && b==c && c==a)
          {System.out.println("YES");}
          else{System.out.println("NO");}
    }}}
}


import java.util.*;
import java.io.*;
 public class ab{
    public static void main(String args[])
    {int x=0,y=0;
        Scanner sc=new Scanner (System.in);
       int t=sc.nextInt();
        for(int i=0;i<t;i++)
        {
      int a=sc.nextInt();
      int b=sc.nextInt();
      int c=sc.nextInt();
      int n=sc.nextInt();
      if(a>=b && a>=c)
      {
          x=a-b;
          y=a-c;
      }
      else if(b>=a && b>=c)
      {
          x=b-a;
          y=b-c;
      }
      else{
          x=c-a;
          y=c-b;
      }n=n-(x+y);
      if(n%3==0)
      {
          System.out.println("Yes");
      }
      else{
          System.out.println("No");
      }
    }}
}


import java.util.Arrays;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();

        for (int i = 1; i <= n; i++) {
            int a = input.nextInt();
            int b = input.nextInt();
            int c = input.nextInt();
            int num = input.nextInt();

            int sum = a + b + c + num;
            if (sum % 3 == 0 && a <= sum / 3 && b <= sum / 3 && c <= sum / 3) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }

    }

}


import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();

        for (int i = 1; i <= n; i++) {
            int a = input.nextInt();
            int b = input.nextInt();
            int c = input.nextInt();
            int num=input.nextInt();
            int array[]=new int[3];
            array[0]=a;
            array[1]=b;
            array[2]=c;
            Arrays.sort(array);
            int total=a+b+c;
            int max=array[2];
           while(true){
               int com=max*3;
               int div=com-num;
               if (div==total){
                   System.out.println("YES");
                   break;
               }
               else if(com==total && num%3==0){
                   System.out.println("YES");
                   break;
               }
               else if(div>total)
               {
                   System.out.println("NO");
                   break;
               }
               max++;
           }

        }

    }

}


import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();

        for (int i = 1; i <= n; i++) {
            int a = input.nextInt();
            int b = input.nextInt();
            int c = input.nextInt();
            int num = input.nextInt();
            int total = a + b + c;
            if (total % 3 != 0 && num % 3 != 0) {

                System.out.println("YES");
            } else if (total % 3 == 0 && num % 3 == 0) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }

        }

    }

}


import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();

        for (int i = 1; i <= n; i++) {
            int a = input.nextInt();
            int b = input.nextInt();
            int c = input.nextInt();
            int num=input.nextInt();
            int array[]=new int[3];
            array[0]=a;
            array[1]=b;
            array[2]=c;
            Arrays.sort(array);
            int total=a+b+c;
            int max=array[2];
           while(true){
               int com=max*3;
               int div=com-num;
               if (div==total){
                   System.out.println("YES");
                   break;
               }
               else if(com==total){
                   System.out.println("YES");
                   break;
               }
               else if(div>total)
               {
                   System.out.println("NO");
                   break;
               }
               max++;
           }

        }

    }

}


import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();

        for (int i = 1; i <= n; i++) {
            int a = input.nextInt();
            int b = input.nextInt();
            int c = input.nextInt();
            int num=input.nextInt();
            int array[]=new int[3];
            array[0]=a;
            array[1]=b;
            array[2]=c;
            Arrays.sort(array);
            if(num==3){
                System.out.println("YES");
            }
            else if(Math.abs(array[2]-num)==3){
                System.out.println("YES");
            }
            else{
                System.out.println("No");
            }

        }

    }

}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class CollectingCoins {
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);

	        int t = sc.nextInt();
	        for (int tc = 0; tc < t; ++tc) {
	            int n = sc.nextInt();
	            ArrayList<Integer> arr = new ArrayList<Integer>();
	            arr.add(sc.nextInt());
	            arr.add(sc.nextInt());
	            arr.add(sc.nextInt());

	            Collections.sort(arr);
	            int dif = arr.get(2) - arr.get(0);
	            dif += arr.get(2) - arr.get(1);

	                dif -= n;
	                if(dif % 3 == 0)
	                    System.out.println("YES");
	                else
	                	System.out.println("NO");
	            }

	        sc.close();
	    }
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class CollectingCoins {
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);

	        int t = sc.nextInt();
	        for (int tc = 0; tc < t; ++tc) {
	        	ArrayList<Integer> arr = new ArrayList<Integer>();
	            arr.add(sc.nextInt());
	            arr.add(sc.nextInt());
	            arr.add(sc.nextInt());
	            int n = sc.nextInt();

	            Collections.sort(arr);
	            System.out.println(arr);
	            int dif = arr.get(2) - arr.get(0);
	            dif += arr.get(2) - arr.get(1);

	            if(n >= dif) {
	                n -= dif;
	                if(n % 3 == 0)
	                    System.out.println("YES");
	                else
	                	System.out.println("NO");
	            }
	            else System.out.println("NO");

	        }

	        sc.close();
	    }
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class CollectingCoins {
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);

	        int t = sc.nextInt();
	        for (int tc = 0; tc < t; ++tc) {
	        	ArrayList<Integer> arr = new ArrayList<Integer>();
	            arr.add(sc.nextInt());
	            arr.add(sc.nextInt());
	            arr.add(sc.nextInt());
	            int n = sc.nextInt();

	            Collections.sort(arr);
	            int dif = arr.get(2) - arr.get(0);
	            dif += arr.get(2) - arr.get(1);

	            if(n >= dif) {
	                n -= dif;
	                if(n % 3 == 0)
	                    System.out.println("YES");
	                else
	                	System.out.println("NO");
	            }
	            else System.out.println("NO");

	        }

	        sc.close();
	    }
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class CollectingCoins {
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);

	        int t = sc.nextInt();
	        for (int tc = 0; tc < t; ++tc) {
	            int n = sc.nextInt();
	            ArrayList<Integer> arr = new ArrayList<Integer>();
	            arr.add(sc.nextInt());
	            arr.add(sc.nextInt());
	            arr.add(sc.nextInt());

	            Collections.sort(arr);
	            System.out.println(arr);
	            int dif = arr.get(2) - arr.get(0);
	            dif += arr.get(2) - arr.get(1);

	                dif -= n;
	                if(dif % 3 == 0)
	                    System.out.println("YES");
	                else
	                	System.out.println("NO");
	            }

	        sc.close();
	    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CollectingCoins {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		// Problem https://codeforces.com/problemset/problem/1294/A
		// For more solutions check https://github.com/jontiboss
		Reader reader = new Reader();
		int tests = reader.nextInt();
		int coins,a,b,c;
		for(int i =0;i<tests;i++) {
			coins = reader.nextInt();
			a = reader.nextInt();
			b = reader.nextInt();
			c = reader.nextInt();
			if((a+b+c+coins)%3==0){
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
		}
	}
	static class Reader
	{
		BufferedReader br;
		StringTokenizer st;

		public Reader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CollectingCoins {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		// Problem https://codeforces.com/problemset/problem/1294/A
		// For more solutions check https://github.com/jontiboss
		Reader reader = new Reader();
		int tests = reader.nextInt();
		int coins,a,b,c;
		for(int i =0;i<tests;i++) {
			coins = reader.nextInt();
			a = reader.nextInt();
			b = reader.nextInt();
			c = reader.nextInt();
			if((a+b+c+coins)%3==0 && (a+b+c+coins)%3>=Math.max(a, Math.max(b,c))){
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
		}
	}
	static class Reader
	{
		BufferedReader br;
		StringTokenizer st;

		public Reader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CollectingCoins {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		// Problem https://codeforces.com/problemset/problem/1294/A
		// For more solutions check https://github.com/jontiboss
		Reader reader = new Reader();
		int tests = reader.nextInt();
		int coins,a,b,c;
		for(int i =0;i<tests;i++) {
			a = reader.nextInt();
			int largest = a;
			b = reader.nextInt();
			if(b>largest) {
				largest = b;
			}
			c = reader.nextInt();
			if(c>largest){
				largest = c;
			}
			coins = reader.nextInt();
			int sum = a+b+c+coins;
			//if you can divide the total sum into three even stacks and the stack value is bigger or equal to the largest number of coins
			//that one of the sisters have."Math.max(a, Math.max(b,c)" could be use to find out the largest value,
			if((sum)%3==0 && (sum)/3>=largest){
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
		}
	}
	static class Reader
	{
		BufferedReader br;
		StringTokenizer st;

		public Reader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CollectingCoins {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		// Problem https://codeforces.com/problemset/problem/1294/A
		// For more solutions check https://github.com/jontiboss
		Reader reader = new Reader();
		int tests = reader.nextInt();
		int coins,a,b,c;
		for(int i =0;i<tests;i++) {
			a = reader.nextInt();
			b = reader.nextInt();
			c = reader.nextInt();
			coins = reader.nextInt();
			if((a+b+c+coins)%3==0 && (a+b+c+coins)/3>=Math.max(a, Math.max(b,c))){
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
		}
	}
	static class Reader
	{
		BufferedReader br;
		StringTokenizer st;

		public Reader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CollectingCoins {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		// Problem https://codeforces.com/problemset/problem/1294/A
		// For more solutions check https://github.com/jontiboss
		Reader reader = new Reader();
		int tests = reader.nextInt();
		int coins,a,b,c;
		for(int i =0;i<tests;i++) {
			a = reader.nextInt();
			b = reader.nextInt();
			c = reader.nextInt();
			coins = reader.nextInt();
			int sum = a+b+c+coins;
			//if you can divide the total sum into three even stacks and the stack value is bigger or equal to the largest number of coins
			//that one of the sisters have.ss
			if((sum)%3==0 && (sum)/3>=Math.max(a, Math.max(b,c))){
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
		}
	}
	static class Reader
	{
		BufferedReader br;
		StringTokenizer st;

		public Reader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}
	}
}


import java.util.*;
public class a1294
{
	public static void main(String[] args) {	Scanner in=new Scanner(System.in);
	int t,a,b,c,n,x,y,A,B,C;
	t=in.nextInt();
	while(t-->0)
	{
		a=in.nextInt();
		b=in.nextInt();
		c=in.nextInt();
		n=in.nextInt();
		x=(a+b+c+n)/3;
		A=(x-a);B=(x-b);C=(x-c);
		y=A+B+C;
		//if(y==n&&(a+A)==(b+B)&&(b+b)==(c+C))
		if(y==n){
		    if(a+A==b+B)
		    {
		        if(b+B==c+C)
		{	System.out.println("YES");}
		else
			System.out.println("NO");
		    }
		else
			System.out.println("NO");
		}
		else
			System.out.println("NO");
	}
	}
}


import java.util.*;
public class a1294
{
	public static void main(String[] args) {	Scanner in=new Scanner(System.in);
		int t,n,a,b,c,x,y;
		t=in.nextInt();
		while(t-->0)
		{
			a=in.nextInt();
			b=in.nextInt();
			c=in.nextInt();
			n=in.nextInt();
			x=a+b+c+n;
			y=x/3;
			if(3*y-a-b-c==n && x%3==0)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}
}


import java.util.*;
public class a1294
{
	public static void main(String[] args) {	Scanner in=new Scanner(System.in);
		int t,n,a,b,c,x,y;
		t=in.nextInt();
		while(t-->0)
		{
			a=in.nextInt();
			b=in.nextInt();
			c=in.nextInt();
			n=in.nextInt();
			x=a+b+c+n;
			y=x/3;
			if(y>=Math.max(a,Math.max(b,c)) && x%3==0)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}
}


import java.util.*;
public class a1294{
public static void main(String args[]){
	Scanner in=new Scanner(System.in);
	int t,a,b,c,n,x;
	t=in.nextInt();
	while(t-->0)
	{
		a=in.nextInt();
		b=in.nextInt();
		c=in.nextInt();
		n=in.nextInt();
		x=(a+b+c+n)/3;
		x=(x-a)+(x-b)+(x-c);
		if(x==n)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}
}


import java.util.*;
public class a1294{
public static void main(String args[]){
	Scanner in=new Scanner(System.in);
	int t,a,b,c,n,x,y,A,B,C;
	t=in.nextInt();
	while(t-->0)
	{
		a=in.nextInt();
		b=in.nextInt();
		c=in.nextInt();
		n=in.nextInt();
		x=(a+b+c+n)/3;
		y=(x-a)+(x-b)+(x-c);

		A=(x-a);B=(x-b);C=(x-c);
		if(y==n||a+A==b+B&&b+b==c+C)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}
}


import java.util.*;
public class a1294{
public static void main(String args[]){
	Scanner in=new Scanner(System.in);
	int t,a,b,c,n,x,y;
	t=in.nextInt();
	while(t-->0)
	{
		a=in.nextInt();
		b=in.nextInt();
		c=in.nextInt();
		n=in.nextInt();
		x=(a+b+c+n)/3;
		y=(x-a)+(x-b)+(x-c);
		if(y==n)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}
}


import java.util.*;

public class codeforce
{
	public static void main(String args[])
	{
		Scanner sj = new Scanner(System.in);
		int t = sj.nextInt();

		while(t-->0){
			int sum = 0;
			for(int i=0;i<4;i++){
				a[i] = sj.nextInt();
			}
			int max = Integer.MIN_VALUE;
			for(int i=0;i<3;i++){
				if(max<a[i]){
					max = a[i];
				}
			}

			for(int i=0;i<3;i++){
				if(max>a[i]){
					sum += (max-a[i]);
				}
			}

			int ans = a[3] - sum;

			if(ans<0 || ans%3!=0){
				System.out.println("NO");
			}else{
				System.out.println("YES");
			}
		}
	}
}


import java.util.*;

public class codeforce
{
	public static void main(String args[])
	{
		Scanner sj = new Scanner(System.in);
		int t = sj.nextInt();

		while(t-->0){
			int a[] = new int[4];
			int sum = 0;
			for(int i=0;i<4;i++){
				a[i] = sj.nextInt();
				sum += a[i];
			}
			if(sum%3==0){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}


import java.util.*;

public class codeforce
{
	public static void main(String args[])
	{
		Scanner sj = new Scanner(System.in);
		int t = sj.nextInt();

		while(t-->0){
			int sum = 0;
			int a[] = new int[4];
			for(int i=0;i<4;i++){
				a[i] = sj.nextInt();
			}
			int max = Integer.MIN_VALUE;
			for(int i=0;i<3;i++){
				if(max<a[i]){
					max = a[i];
				}
			}

			for(int i=0;i<3;i++){
				if(max>a[i]){
					sum += (max-a[i]);
				}
			}

			int ans = a[3] - sum;

			if(ans<0 || ans%3!=0){
				System.out.println("NO");
			}else{
				System.out.println("YES");
			}
		}
	}
}


import java.util.*;

public class codeforce
{
	public static void main(String args[])
	{
		Scanner sj = new Scanner(System.in);
		int t = sj.nextInt();

		while(t-->0){
			int sum = 0;
			int a[] = new int[4];
			for(int i=0;i<4;i++){
				a[i] = sj.nextInt();
			}
			int max = Integer.MIN_VALUE;
			for(int i=0;i<3;i++){
				if(max<a[i]){
					max = a[i];
				}
			}

			for(int i=0;i<3;i++){
				if(max>a[i]){
					sum += (max-a[i]);
				}
			}

			int ans = a[3] - sum;

			if(ans%3==0){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}


import java.util.*;

public class codeforce
{
	public static void main(String args[])
	{
		Scanner sj = new Scanner(System.in);
		int t = sj.nextInt();

		while(t-->0){

			long sum = 0;
			for(int i=0;i<4;i++){
				int x = sj.nextLong();
				sum += x;
			}
			if(sum%3==0){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}


import java.util.*;

public class codeforce
{
	public static void main(String args[])
	{
		Scanner sj = new Scanner(System.in);
		int t = sj.nextInt();

		while(t-->0){
			int sum = 0;
			int a[] = new int[4];
			for(int i=0;i<4;i++){
				a[i] = sj.nextInt();
			}
			int max = Integer.MIN_VALUE;
			for(int i=0;i<3;i++){
				if(max<a[i]){
					max = a[i];
				}
			}

			for(int i=0;i<3;i++){
				if(max>a[i]){
					sum += (max-a[i]);
				}
			}

			int ans = a[3] - sum;

			if(ans%3==0 && n>2){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}


import java.util.*;

public class codeforce
{
	public static void main(String args[])
	{
		Scanner sj = new Scanner(System.in);
		int t = sj.nextInt();

		while(t-->0){
			int sum = 0;
			int a[] = new int[4];
			for(int i=0;i<4;i++){
				a[i] = sj.nextInt();
			}
			int max = Integer.MIN_VALUE;
			for(int i=0;i<3;i++){
				if(max<a[i]){
					max = a[i];
				}
			}

			for(int i=0;i<3;i++){
				if(max>a[i]){
					sum += (max-a[i]);
				}
			}

			int ans = a[3] - sum;

			if(ans%3==0 && a[3]>2){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}


import java.util.*;

public class codeforce
{
	public static void main(String args[])
	{
		Scanner sj = new Scanner(System.in);
		int t = sj.nextInt();

		while(t-->0){

			long sum = 0;
			for(int i=0;i<4;i++){
				long x = sj.nextLong();
				sum += x;
			}
			if(sum%3==0){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}


import java.util.*;
public class CollectingCoins {
	public static Scanner scn = new Scanner(System.in);

	public static void main(String[] args) {
		int t = scn.nextInt();
		while(t-->0) {
			long sum = 0;
			long[] a = new long[3];
			for(int i=0;i<3;i++) {
				a[i] = scn.nextLong();
				sum += a[i];
			}
			long n = scn.nextInt();
			sum += n ;
			/*Arrays.sort(a);
			n -= (a[2] - a[0]);
			n -= (a[2] - a[1]);*/
			if(sum%3 == 0) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}

	}

}


import java.util.*;
public class CollectingCoins {
	public static Scanner scn = new Scanner(System.in);

	public static void main(String[] args) {
		int t = scn.nextInt();
		while(t-->0) {
			long[] a = new long[3];
			for(int i=0;i<3;i++) {
				a[i] = scn.nextLong();
			}
			long n = scn.nextInt();
			Arrays.sort(a);
			n -= (a[2] - a[0]);
			n -= (a[2] - a[1]);
			if(n%3 == 0) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}

	}

}


import java.util.*;
public class CollectingCoins {
	public static Scanner scn = new Scanner(System.in);

	public static void main(String[] args) {
		int t = scn.nextInt();
		while(t-->0) {
			long sum = 0;
			long[] a = new long[3];
			for(int i=0;i<3;i++) {
				a[i] = scn.nextLong();
				//sum += a[i];
			}
			long n = scn.nextInt();
			//sum += n ;
			Arrays.sort(a);
			n -= (a[2] - a[0]);
			n -= (a[2] - a[1]);
			if(sum%3 != 0 || n<0) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}

	}

}


import java.util.*;
public class CollectingCoins {
	public static Scanner scn = new Scanner(System.in);

	public static void main(String[] args) {
		int t = scn.nextInt();
		while(t-->0) {
			long sum = 0;
			long[] a = new long[3];
			for(int i=0;i<3;i++) {
				a[i] = scn.nextLong();
				//sum += a[i];
			}
			long n = scn.nextInt();
			//sum += n ;
			Arrays.sort(a);
			n -= (a[2] - a[0]);
			n -= (a[2] - a[1]);
			if(n%3 != 0 || n<0) {
				System.out.println("NO");
			}else {
				System.out.println("YES");
			}
		}

	}

}


import java.util.*;
public class CollectingCoins {
	public static Scanner scn = new Scanner(System.in);

	public static void main(String[] args) {
		int t = scn.nextInt();
		while(t-->0) {
			int[] a = new int[3];
			for(int i=0;i<3;i++) {
				a[i] = scn.nextInt();
			}
			int n = scn.nextInt();
			Arrays.sort(a);
			n -= (a[2] - a[0]);
			n -= (a[2] - a[1]);
			if(n%3 == 0) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}

	}

}


#include<iostream>
using namespace std;
int main()
{
    int f;
    cin>>f;
    while(f--)
    {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int e=a+b+c+d;
    if(e%3==0 && e/3>=a && e/3>=b && e/3>=c)
    cout<<"yes"<<"\n";
    else
    cout<<"no"<<"\n";
    }
}


#include <iostream>
#include <cmath>
#define ll long long
using namespace std;

int main()
{
    ll  t;
    cin>>t;
	for (ll i=0; i<t; i++)
	{
		ll a, b, c, n,l,d;
		cin>>a>>b>>c>>n;
		l=max(a,b);
		d=max(l, c);

		ll e,f,g;
		e=d-a;

		f=d-b;
		g=d-c;
		if((n-e-f-g)%3==0 && (n-e-f-g)>=0)
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}

	}

}


#include<stdio.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    int a,b,c,n;
    for(int i=0;i<t;i++){
        cin>>a>>b>>c>>n;
        if(a==b && b==c){
            if(n%3==0){
                cout<<"YES"<<endl;
            }
            else{
                cout<<"NO"<<endl;
            }
        }
        else if(a==b && a>c){
            if(n>=a-c){
                n=n-(a-c);
                if(n%3==0){
                    cout<<"YES"<<endl;
                }
                else{
                    cout<<"NO"<<endl;
                }
            }
            else{
                cout<<"NO"<<endl;
            }
        }
        else if(a==b && a<c){
            if(n>=(2*(c-a))){
                n=n-(2*(c-a));
                if(n%3==0){
                    cout<<"YES"<<endl;
                }
                else{
                    cout<<"NO"<<endl;
                }
            }
            else{
                cout<<"NO"<<endl;
            }
        }
        else if(c==b && b>a){
            if(n>=b-a){
                n=n-(b-a);
                if(n%3==0){
                    cout<<"YES"<<endl;
                }
                else{
                    cout<<"NO"<<endl;
                }
            }
            else{
                cout<<"NO"<<endl;
            }
        }
        else if(c==b && b<a){
            if(n>=(2*(a-b))){
                n=n-(2*(a-c));
                if(n%3==0){
                    cout<<"YES"<<endl;
                }
                else{
                    cout<<"NO"<<endl;
                }
            }
            else{
                cout<<"NO"<<endl;
            }
        }
        else if(a==c && a>b){
            if(n>=a-b){
                n=n-(a-b);
                if(n%3==0){
                    cout<<"YES"<<endl;
                }
                else{
                    cout<<"NO"<<endl;
                }
            }
            else{
                cout<<"NO"<<endl;
            }
        }
        else if(a==c && a<b){
            if(n>=(2*(b-a))){
                n=n-(2*(b-a));
                if(n%3==0){
                    cout<<"YES"<<endl;
                }
                else{
                    cout<<"NO"<<endl;
                }
            }
            else{
                cout<<"NO"<<endl;
            }
        }
        else{
            if(a>b && a>c){
                if(n>=(a-b)+(a-c)){
                    n=n-(a-b)-(a-c);
                    if(n%3==0){
                        cout<<"YES"<<endl;
                    }
                    else{
                        cout<<"NO";
                    }
                }
                else{
                    cout<<"NO"<<endl;
                }
            }
            else if(b>a && b>c){
                if(n>=(b-a)+(b-c)){
                    n=n-(b-a)-(b-c);
                    if(n%3==0){
                        cout<<"YES"<<endl;
                    }
                    else{
                        cout<<"NO";
                    }
                }
                else{
                    cout<<"NO"<<endl;
                }
            }
            else if(c>a && c>b){
                if(n>=(c-b)+(c-a)){
                    n=n-(c-b)-(c-a);
                    if(n%3==0){
                        cout<<"YES"<<endl;
                    }
                    else{
                        cout<<"NO";
                    }
                }
                else{
                    cout<<"NO"<<endl;
                }
            }
        }
    }
}


#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int NMAX = 10005;
const int KMAX = 7; //five

const int JMAX = 15;

int n,m,K;

int a[NMAX][KMAX];

int rmq[NMAX][KMAX][JMAX];

bool check(int st,int dr){
	int k=log2(dr-st+1);

	long long cnt=0;
	for(int j=1;j<=m;++j){
		cnt+=max(rmq[st][j][k],rmq[dr-(1<<k)+1][j][k]);
	}

	if(cnt<=K)
		return 1;

	return 0;
}

int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);

	scanf("%d%d%d",&n,&m,&K);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			scanf("%d",&a[i][j]);

	//precalc RMQ
	for(int j=1;j<=m;++j){ //for each droid type
		for(int i=1;i<=n;++i)
			rmq[i][j][0]=a[i][j];

		for(int k=1;(1<<k)<=n+1;++k)
			for(int i=1;i+(1<<k)<=n+1;++i)
				rmq[i][j][k]=max(rmq[i][j][k-1],rmq[i+(1<<(k-1))][j][k-1]);
	}

	/*
	for(int j=1;j<=m;++j){
		printf("rmq for %d\n",j);

		for(int k=0;(1<<k)<=n+1;++k){
			for(int i=1;i+(1<<k)<=n+1;++i)
				printf("%d ",rmq[i][j][k]);
			printf("\n");
		}
	}*/

	int ans=-1,ansl=-1;

	int st=1,dr=1;
	while(dr<=n){
		if(check(st,dr)){
			int l=dr-st+1;
			if(l>ansl){
				ansl=l;
				ans=st;
			}
			dr++;
		}
		else
			st++;
	}

	int x;
	for(int j=1;j<=m;++j){
		int k=log2(ansl);
		x=max(rmq[ans][j][k],rmq[ans+ansl-(1<<k)][j][k]);
		printf("%d ",x);
	}
	return 0;
}


#include <cstdio>
#include <algorithm>

using namespace std;

const int NMAX = 10005;
const int KMAX = 7; //five

const int JMAX = 15;

int n,m,K;

int a[NMAX][KMAX];

int rmq[NMAX][KMAX][JMAX];

int log2[NMAX];

int check(int l){
	int k=log2[l];

	for(int i=1;i+(1<<k)<=n+1;++i){
		long long cnt=0;
		for(int j=1;j<=m;++j){
			cnt+=max(rmq[i][j][k],rmq[i+l-(1<<k)][j][k]);
		}

		if(cnt<=K)
			return i;
	}
	return 0;
}

int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);

	scanf("%d%d%d",&n,&m,&K);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			scanf("%d",&a[i][j]);

	//precalc log
	for(int i=2;i<=n;++i)
		log2[i]=log2[i/2]+1;

	//precalc RMQ
	for(int j=1;j<=m;++j){ //for each droid type
		for(int i=1;i<=n;++i)
			rmq[i][j][0]=a[i][j];

		for(int k=1;(1<<k)<=n+1;++k)
			for(int i=1;i+(1<<k)<=n+1;++i)
				rmq[i][j][k]=max(rmq[i][j][k-1],rmq[i+(1<<(k-1))][j][k-1]);
	}

	/*
	for(int j=1;j<=m;++j){
		printf("rmq for %d\n",j);

		for(int k=0;(1<<k)<=n+1;++k){
			for(int i=1;i+(1<<k)<=n+1;++i)
				printf("%d ",rmq[i][j][k]);
			printf("\n");
		}
	}*/

	int st=1,dr=n,l,ans=-1,ansl=-1;
	while(st<=dr){
	    l=(st+dr)/2;

		int checked=check(l);
		if(checked!=0){
			st=l+1;
			if(l>ansl){
				ansl=l;
				ans=checked;
			}
		}
		else
			dr=l-1;
	}

	int x;
	for(int j=1;j<=m;++j){
		int k=log2[ansl];
		x=max(rmq[ans][j][k],rmq[ans+ansl-(1<<k)][j][k]);
		printf("%d ",x);
	}
	return 0;
}


#include <cstdio>
#include <algorithm>

using namespace std;

const int NMAX = 10005;
const int KMAX = 7; //five

const int JMAX = 15;

int n,m,K;

int a[NMAX][KMAX];

int rmq[NMAX][KMAX][JMAX];

int log2[NMAX];

int check(int l){
	int k=log2[l];

	for(int i=1;i+(1<<k)<=n+1;++i){
		int cnt=0;
		for(int j=1;j<=m;++j){
			cnt+=max(rmq[i][j][k],rmq[i+l-(1<<k)-1][j][k]);
		}

		if(cnt<=K)
			return i;
	}
	return 0;
}

int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);

	scanf("%d%d%d",&n,&m,&K);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			scanf("%d",&a[i][j]);

	//precalc log
	for(int i=2;i<=n;++i)
		log2[i]=log2[i/2]+1;

	//precalc RMQ
	for(int j=1;j<=m;++j){ //for each droid type
		for(int i=1;i<=n;++i)
			rmq[i][j][0]=a[i][j];

		for(int k=1;(1<<k)<=n;++k)
			for(int i=1;i+(1<<k)<=n+1;++i)
				rmq[i][j][k]=max(rmq[i][j][k-1],rmq[i+(1<<(k-1))][j][k-1]);
	}

	/*
	for(int j=1;j<=m;++j){
		printf("rmq for %d\n",j);

		for(int k=0;(1<<k)<=n;++k){
			for(int i=1;i+(1<<k)<=n+1;++i)
				printf("%d ",rmq[i][j][k]);
			printf("\n");
		}
	}*/

	int st=1,dr=n,l,ans=-1,ansl=-1;
	while(st<=dr){
	    l=(st+dr)/2;

		int checked=check(l);
		if(checked!=0){
			st=l+1;
			if(l>ansl){
				ansl=l;
				ans=checked;
			}
		}
		else
			dr=l-1;
	}

	int x;
	for(int j=1;j<=m;++j){
		int k=log2[ansl];
		x=max(rmq[ans][j][k],rmq[ans+ansl-(1<<k)-1][j][k]);
		printf("%d ",x);
	}
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int NMAX = 100005;
const int KMAX = 7; //five

const int JMAX = 20;

int n,m,K;

int a[NMAX][KMAX];

int rmq[NMAX][KMAX][JMAX];

bool check(int st,int dr){
	int k=log2(dr-st+1);

	long long cnt=0;
	for(int j=1;j<=m;++j){
		cnt+=max(rmq[st][j][k],rmq[dr-(1<<k)+1][j][k]);
	}

	if(cnt<=K)
		return 1;

	return 0;
}

int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);

	scanf("%d%d%d",&n,&m,&K);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			scanf("%d",&a[i][j]);

	//precalc RMQ
	for(int j=1;j<=m;++j){ //for each droid type
		for(int i=1;i<=n;++i)
			rmq[i][j][0]=a[i][j];

		for(int k=1;(1<<k)<=n+1;++k)
			for(int i=1;i+(1<<k)<=n+1;++i)
				rmq[i][j][k]=max(rmq[i][j][k-1],rmq[i+(1<<(k-1))][j][k-1]);
	}

	/*
	for(int j=1;j<=m;++j){
		printf("rmq for %d\n",j);

		for(int k=0;(1<<k)<=n+1;++k){
			for(int i=1;i+(1<<k)<=n+1;++i)
				printf("%d ",rmq[i][j][k]);
			printf("\n");
		}
	}*/

	int ans=-1,ansl=-1;

	int st=1,dr=1;
	while(dr<=n){
		if(st>dr)
			dr=st;
		if(check(st,dr)){
			int l=dr-st+1;
			if(l>ansl){
				ansl=l;
				ans=st;
			}
			dr++;
		}
		else
			st++;
	}

	int x;
	for(int j=1;j<=m;++j){
		int k=log2(ansl);
		x=max(rmq[ans][j][k],rmq[ans+ansl-(1<<k)][j][k]);
		printf("%d ",x);
	}
	return 0;
}


#include <cstdio>
#include <algorithm>

using namespace std;

const int NMAX = 10005;
const int KMAX = 7; //five

const int JMAX = 15;

int n,m,K;

int a[NMAX][KMAX];

int rmq[NMAX][KMAX][JMAX];

int log2[NMAX];

int check(int l){
	int k=log2[l];

	for(int i=1;i+(1<<k)<=n+1;++i){
		int cnt=0;
		for(int j=1;j<=m;++j){
			cnt+=max(rmq[i][j][k],rmq[i+l-(1<<k)-1][j][k]);
		}

		if(cnt<=K)
			return i;
	}
	return 0;
}

int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);

	scanf("%d%d%d",&n,&m,&K);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			scanf("%d",&a[i][j]);

	//precalc log
	for(int i=2;i<=n;++i)
		log2[i]=log2[i/2]+1;

	//precalc RMQ
	for(int j=1;j<=m;++j){ //for each droid type
		for(int i=1;i<=n;++i)
			rmq[i][j][0]=a[i][j];

		for(int k=1;(1<<k)<=n;++k)
			for(int i=1;i+(1<<k)<=n+1;++i)
				rmq[i][j][k]=max(rmq[i][j][k-1],rmq[i+(1<<(k-1))][j][k-1]);
	}

	/*
	for(int j=1;j<=m;++j){
		printf("rmq for %d\n",j);

		for(int k=0;(1<<k)<=n;++k){
			for(int i=1;i+(1<<k)<=n+1;++i)
				printf("%d ",rmq[i][j][k]);
			printf("\n");
		}
	}*/

	int st=1,dr=n,l,ans=-1,ansl=-1;
	while(st<=dr){
	    l=(st+dr)/2;

		int checked=check(l);
		if(checked){
			st=l+1;
			ansl=l;
			ans=checked;
		}
		else
			dr=l-1;
	}

	int x;
	for(int j=1;j<=m;++j){
		int k=log2[ansl];
		x=max(rmq[ans][j][k],rmq[ans+ansl-(1<<k)-1][j][k]);
		printf("%d ",x);
	}
	return 0;
}


#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;

#define     LL                      long long int
#define     LD                      long double
#define     ULL                     unsigned long long int

#define     pii                     pair<int, int>
#define     ump                     unordered_map
#define     mp                      make_pair
#define     mt                      make_tuple
#define     pb                      push_back
#define     ff                      first
#define     ss                      second
#define     SZ(x)                   (int)x.size()
#define     all(x)                  x.begin(), x.end()
#define     lb(x, y)                lower_bound(all(x), y)
#define     fill2d(arr, a, b, v)    fill(&arr[0][0], &arr[0][0] + a * b, v)
#define     fill3d(arr, a, b, c, v) fill(&arr[0][0], &arr[0][0] + a * b * c, v)
#define     rep(i, begin, end)      for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define     sp(x)                   setprecision(x) << fixed
#define     what_is(x)              cout << #x << " is " << x << endl
//#define     I64                     ll

#define     PI                      acos(-1.0)
#define     EPS                     1e-12
//#define     mx                      200010
#define     S_SIZE                  2000010

const LL inf = 1000000000;
const LL mod = 1000000000 + 7;

inline void IO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
inline int dcmp (LD x) { return x < -EPS ? -1 : (x > EPS); }

template<class T> inline int CHECK(T MASK, int i) { return (MASK >> i) & 1; }
template<class T> inline T ON(T MASK, int i) { return MASK | (T(1) << i); }
template<class T> inline T OFF(T MASK, int i) { return MASK & (~(T(1) << i)); }
template<typename T> inline int CNT(T MASK) {
    if (numeric_limits<T>::digits <= numeric_limits<unsigned int>::digits) return __builtin_popcount(MASK);
    else return __builtin_popcountll(MASK);
}
template<class T> inline int RIGHT(T MASK) { return log2(MASK & -MASK); }

int dx4[] = { 0, 0, -1, +1 }; int dy4[] = { +1, -1, 0, 0 };
int dx8[] = { 1, 1, 0, -1, -1, -1, 0, 1, 0 }; int dy8[] = { 0, 1, 1, 1, 0, -1, -1, -1, 0 };

inline void I(int& a) { scanf("%d", &a); } inline void I(LL& a) { scanf("%I64d", &a); }
inline void I(ULL& a) { scanf("%I64u", &a); } inline void I(char* a) { scanf("%s", a); }
char Iarr[S_SIZE]; inline void I(string& a) { scanf("%s", Iarr); a = Iarr; }
template<typename T, typename... Args>
void I(T& a, Args&... args) { I(a); I(args...); }

inline void OUT(int a) { printf("%d", a); } inline void OUT(LL a) { printf("%I64d", a); }
inline void OUT(const char* a) { printf("%s", a); } inline void OUT(char* a) { printf("%s", a); }
inline void OUT(bool a) { printf("%d", a); } inline void OUT(string a) { rep(it, a.begin(), a.end()) printf("%c", *it); }
inline void OUT(ULL a) { printf("%I64u", a); }
template<typename T, typename... Args>
void OUT(T a, Args... args) { OUT(a); OUT(" "); OUT(args...); }
template<typename... Args>
void O(Args... args) { OUT(args...); OUT("\n"); }

template<typename T1, typename T2>
inline ostream& operator<<(ostream& os, pair<T1, T2> p) { os << "{" << p.first << ", " << p.second << "}"; return os; }
template<typename T>
inline ostream& operator<<(ostream& os, vector<T>& a) { os << "["; for (int i = 0; i < (int)a.size(); i++) { if (i) os << ", "; os << a[i]; } os << "]"; return os; }

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}

// mp.reserve(1024); mp.max_load_factor(0.25);
// head

const int M = 200010; // maximum number of cubes

struct LCA
{
    /* 0 indexed */
    int n;
    int *l;
    int **p;
    int **mn;
    int **mx;
    LL **sum;
    /* parent, min, max, sum */
    int LOG;
    int *logs;
    vector<pii > *g;
    void init1(int nn)
    {
        n = nn;
        l = new int[nn];
        p = new int*[nn];
        mn = new int*[nn];
        mx = new int*[nn];
        sum = new LL*[nn];
        LOG = log2(nn) + 2;
        for (int i = 0; i < nn; i++) {
            p[i] = new int[LOG];
            mn[i] = new int[LOG];
            mx[i] = new int[LOG];
            sum[i] = new LL[LOG];
        }
        g = new vector<pii >[nn];
    }
    void init2(int nn, vector<pii> gg[])
    {
        n = nn;
        l = new int[nn];
        p = new int*[nn];
        mn = new int*[nn];
        mx = new int*[nn];
        sum = new LL*[nn];
        LOG = log2(nn) + 2;
        for (int i = 0; i < nn; i++) {
            p[i] = new int[LOG];
            mn[i] = new int[LOG];
            mx[i] = new int[LOG];
            sum[i] = new LL[LOG];
        }
        g = new vector<pii >[nn];
        for (int i = 0; i < nn; i++) {
            for (auto x : gg[i]) {
                g[i].push_back(x);
            }
        }
    }
    void addEdge(int u, int v, int w)
    {
        g[u].push_back(mp(v, w));
        g[v].push_back(mp(u, w));
    }
    void dfs(int u, int pp, int ll)
    {
        l[u] = ll;
        p[u][0] = pp;
        for (auto x : g[u]) {
            if (x.ff != pp) {
                mn[x.ff][0] = mx[x.ff][0] = sum[x.ff][0] = x.ss;
                dfs(x.ff, u, ll + 1);
            }
        }
    }
    void build()
    {
        dfs(0, -1, 0);
        for (int i = 1; i < LOG; i++) {
            for (int j = 0; j < n; j++) {
                if (p[j][i-1] != -1) {
                    mn[j][i] = min(mn[j][i-1], mn[p[j][i-1]][i-1]);
                    mx[j][i] = max(mx[j][i-1], mx[p[j][i-1]][i-1]);
                    sum[j][i] = sum[j][i-1] + sum[p[j][i-1]][i-1];
                    p[j][i] = p[p[j][i-1]][i-1];
                }
                else {
                    p[j][i] = -1;
                    mn[j][i] = INT_MAX;
                    mx[j][i] = INT_MIN;
                    sum[j][i] = 0;
                }
            }
        }
    }
    int lca(int u, int v)
    {
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                v = p[v][i];
            }
        }
        if (u == v) return u;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                u = p[u][i];
                v = p[v][i];
            }
        }
        return p[u][0];
    }
    int minimum(int u, int v)
    {
        int ret = INT_MAX;
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                ret = min(ret, mn[v][i]);
                v = p[v][i];
            }
        }
        if (u == v) return ret;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                ret = min(ret, mn[u][i]);
                ret = min(ret, mn[v][i]);
                u = p[u][i];
                v = p[v][i];
            }
        }
        ret = min(ret, mn[u][0]);
        ret = min(ret, mn[v][0]);
        return ret;
    }
    int maximum(int u, int v)
    {
        int ret = INT_MIN;
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                ret = max(ret, mx[v][i]);
                v = p[v][i];
            }
        }
        if (u == v) return ret;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                ret = max(ret, mx[u][i]);
                ret = max(ret, mx[v][i]);
                u = p[u][i];
                v = p[v][i];
            }
        }
        ret = max(ret, mx[u][0]);
        ret = max(ret, mx[v][0]);
        return ret;
    }
    LL accumulation(int u, int v)
    {
        LL ret = 0;
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                ret += sum[v][i];
                v = p[v][i];
            }
        }
        if (u == v) return ret;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                ret += sum[u][i];
                ret += sum[v][i];
                u = p[u][i];
                v = p[v][i];
            }
        }
        ret += sum[u][0];
        ret += sum[v][0];
        return ret;
    }
    void fast_g()
    {
        logs = new int[n+1];
        logs[1] = 0;
        for (int i = 2; i <= n; i++)
            logs[i] = logs[i/2] + 1;
    }
    int fast_min(int l, int r)
    {
        int j = logs[r-l+1];
        return min(mn[r][j], mn[l+(1<<j)-1][j]);
    }
    int fast_max(int l, int r)
    {
        int j = logs[r-l];
        return max(mx[r][j], mx[r-(1<<j)][j]);
    }
};

int main()
{
    int n, m, k;
    I(n, m, k);
    int a[n][m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            I(a[i][j]);
        }
    }
    LCA lca[m];
    for (int i = 0; i < m; i++) {
        lca[i].init1(n + 1);
        for (int j = 0; j < n; j++) {
            lca[i].addEdge(j, j + 1, a[j][i]);
        }
        lca[i].build();
        lca[i].fast_g();
    }
    int ans = INT_MIN;
    vector<int> v(m);
    for (int i = 0; i < n; i++) {
        int low = i, high = n - 1;
        bool ok = 0;
        while (low < high) {
            int mid = (low + high + 1) / 2;
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += lca[j].fast_max(i, mid + 1);
            }
            if (sum <= k) {
                low = mid;
            }
            else {
                high = mid - 1;
            }
        }
        int sum = 0;
        for (int j = 0; j < m; j++) {
            sum += lca[j].fast_max(i, low + 1);
        }
        if (sum <= k) {
            int temp = low - i + 1;
            if (temp > ans) {
                ans = temp;
                for (int j = 0; j < m; j++) {
                    v[j] = lca[j].fast_max(i, low + 1);
//                    error(j, i, low);
                }
            }

        }
    }
//    error(ans);
    for (int i = 0; i < m; i++) {
        printf("%d ", v[i]);
    }
//    error(lca[0].maximum(0, 5));

    return 0;
}


#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;

#define     LL                      long long int
#define     LD                      long double
#define     ULL                     unsigned long long int

#define     pii                     pair<int, int>
#define     ump                     unordered_map
#define     mp                      make_pair
#define     mt                      make_tuple
#define     pb                      push_back
#define     ff                      first
#define     ss                      second
#define     SZ(x)                   (int)x.size()
#define     all(x)                  x.begin(), x.end()
#define     lb(x, y)                lower_bound(all(x), y)
#define     fill2d(arr, a, b, v)    fill(&arr[0][0], &arr[0][0] + a * b, v)
#define     fill3d(arr, a, b, c, v) fill(&arr[0][0], &arr[0][0] + a * b * c, v)
#define     rep(i, begin, end)      for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define     sp(x)                   setprecision(x) << fixed
#define     what_is(x)              cout << #x << " is " << x << endl
//#define     I64                     ll

#define     PI                      acos(-1.0)
#define     EPS                     1e-12
//#define     mx                      200010
#define     S_SIZE                  2000010

const LL inf = 1000000000;
const LL mod = 1000000000 + 7;

inline void IO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
inline int dcmp (LD x) { return x < -EPS ? -1 : (x > EPS); }

template<class T> inline int CHECK(T MASK, int i) { return (MASK >> i) & 1; }
template<class T> inline T ON(T MASK, int i) { return MASK | (T(1) << i); }
template<class T> inline T OFF(T MASK, int i) { return MASK & (~(T(1) << i)); }
template<typename T> inline int CNT(T MASK) {
    if (numeric_limits<T>::digits <= numeric_limits<unsigned int>::digits) return __builtin_popcount(MASK);
    else return __builtin_popcountll(MASK);
}
template<class T> inline int RIGHT(T MASK) { return log2(MASK & -MASK); }

int dx4[] = { 0, 0, -1, +1 }; int dy4[] = { +1, -1, 0, 0 };
int dx8[] = { 1, 1, 0, -1, -1, -1, 0, 1, 0 }; int dy8[] = { 0, 1, 1, 1, 0, -1, -1, -1, 0 };

inline void I(int& a) { scanf("%d", &a); } inline void I(LL& a) { scanf("%I64d", &a); }
inline void I(ULL& a) { scanf("%I64u", &a); } inline void I(char* a) { scanf("%s", a); }
char Iarr[S_SIZE]; inline void I(string& a) { scanf("%s", Iarr); a = Iarr; }
template<typename T, typename... Args>
void I(T& a, Args&... args) { I(a); I(args...); }

inline void OUT(int a) { printf("%d", a); } inline void OUT(LL a) { printf("%I64d", a); }
inline void OUT(const char* a) { printf("%s", a); } inline void OUT(char* a) { printf("%s", a); }
inline void OUT(bool a) { printf("%d", a); } inline void OUT(string a) { rep(it, a.begin(), a.end()) printf("%c", *it); }
inline void OUT(ULL a) { printf("%I64u", a); }
template<typename T, typename... Args>
void OUT(T a, Args... args) { OUT(a); OUT(" "); OUT(args...); }
template<typename... Args>
void O(Args... args) { OUT(args...); OUT("\n"); }

template<typename T1, typename T2>
inline ostream& operator<<(ostream& os, pair<T1, T2> p) { os << "{" << p.first << ", " << p.second << "}"; return os; }
template<typename T>
inline ostream& operator<<(ostream& os, vector<T>& a) { os << "["; for (int i = 0; i < (int)a.size(); i++) { if (i) os << ", "; os << a[i]; } os << "]"; return os; }

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}

// mp.reserve(1024); mp.max_load_factor(0.25);
// head

const int M = 200010; // maximum number of cubes

struct LCA
{
    /* 0 indexed */
    int n;
    int *l;
    int **p;
    int **mn;
    int **mx;
    LL **sum;
    /* parent, min, max, sum */
    int LOG;
    int *logs;
    vector<pii > *g;
    void init1(int nn)
    {
        n = nn;
        l = new int[nn];
        p = new int*[nn];
        mn = new int*[nn];
        mx = new int*[nn];
        sum = new LL*[nn];
        LOG = log2(nn) + 2;
        for (int i = 0; i < nn; i++) {
            p[i] = new int[LOG];
            mn[i] = new int[LOG];
            mx[i] = new int[LOG];
            sum[i] = new LL[LOG];
        }
        g = new vector<pii >[nn];
    }
    void init2(int nn, vector<pii> gg[])
    {
        n = nn;
        l = new int[nn];
        p = new int*[nn];
        mn = new int*[nn];
        mx = new int*[nn];
        sum = new LL*[nn];
        LOG = log2(nn) + 2;
        for (int i = 0; i < nn; i++) {
            p[i] = new int[LOG];
            mn[i] = new int[LOG];
            mx[i] = new int[LOG];
            sum[i] = new LL[LOG];
        }
        g = new vector<pii >[nn];
        for (int i = 0; i < nn; i++) {
            for (auto x : gg[i]) {
                g[i].push_back(x);
            }
        }
    }
    void addEdge(int u, int v, int w)
    {
        g[u].push_back(mp(v, w));
        g[v].push_back(mp(u, w));
    }
    void dfs(int u, int pp, int ll)
    {
        l[u] = ll;
        p[u][0] = pp;
        for (auto x : g[u]) {
            if (x.ff != pp) {
                mn[x.ff][0] = mx[x.ff][0] = sum[x.ff][0] = x.ss;
                dfs(x.ff, u, ll + 1);
            }
        }
    }
    void build()
    {
        dfs(0, -1, 0);
        for (int i = 1; i < LOG; i++) {
            for (int j = 0; j < n; j++) {
                if (p[j][i-1] != -1) {
                    mn[j][i] = min(mn[j][i-1], mn[p[j][i-1]][i-1]);
                    mx[j][i] = max(mx[j][i-1], mx[p[j][i-1]][i-1]);
                    sum[j][i] = sum[j][i-1] + sum[p[j][i-1]][i-1];
                    p[j][i] = p[p[j][i-1]][i-1];
                }
                else {
                    p[j][i] = -1;
                    mn[j][i] = INT_MAX;
                    mx[j][i] = INT_MIN;
                    sum[j][i] = 0;
                }
            }
        }
    }
    int lca(int u, int v)
    {
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                v = p[v][i];
            }
        }
        if (u == v) return u;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                u = p[u][i];
                v = p[v][i];
            }
        }
        return p[u][0];
    }
    int minimum(int u, int v)
    {
        int ret = INT_MAX;
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                ret = min(ret, mn[v][i]);
                v = p[v][i];
            }
        }
        if (u == v) return ret;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                ret = min(ret, mn[u][i]);
                ret = min(ret, mn[v][i]);
                u = p[u][i];
                v = p[v][i];
            }
        }
        ret = min(ret, mn[u][0]);
        ret = min(ret, mn[v][0]);
        return ret;
    }
    int maximum(int u, int v)
    {
        int ret = INT_MIN;
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                ret = max(ret, mx[v][i]);
                v = p[v][i];
            }
        }
        if (u == v) return ret;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                ret = max(ret, mx[u][i]);
                ret = max(ret, mx[v][i]);
                u = p[u][i];
                v = p[v][i];
            }
        }
        ret = max(ret, mx[u][0]);
        ret = max(ret, mx[v][0]);
        return ret;
    }
    LL accumulation(int u, int v)
    {
        LL ret = 0;
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                ret += sum[v][i];
                v = p[v][i];
            }
        }
        if (u == v) return ret;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                ret += sum[u][i];
                ret += sum[v][i];
                u = p[u][i];
                v = p[v][i];
            }
        }
        ret += sum[u][0];
        ret += sum[v][0];
        return ret;
    }
    void fast_g()
    {
        logs = new int[n+2];
        logs[1] = 0;
        for (int i = 2; i <= n; i++)
            logs[i] = logs[i/2] + 1;
    }
    int fast_min(int l, int r)
    {
        int j = logs[r-l+1];
        return min(mn[r][j], mn[l+(1<<j)-1][j]);
    }
    int fast_max(int l, int r)
    {
        int j = logs[r-l];
        //error(l, r, j, mx[r][j], mx[l+(1<<j)][j]);
        return max(mx[r][j], mx[l+(1<<j)][j]);
    }
};

int main()
{
    int aaa;
    int n, m, k;
    I(n, m, k);
    int a[n][m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            I(a[i][j]);
        }
    }
    LCA lca[m];
    for (int i = 0; i < m; i++) {
        lca[i].init1(n + 1);
        for (int j = 0; j < n; j++) {
            lca[i].addEdge(j, j + 1, a[j][i]);
        }
        lca[i].build();
        lca[i].fast_g();
    }
    int ans = INT_MIN;
    vector<int> v(m);
    for (int i = 0; i < n; i++) {
        int low = i, high = n - 1;
        bool ok = 0;
        while (low < high) {
            int mid = (low + high + 1) / 2;
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += lca[j].fast_max(i, mid + 1);
            }
            if (sum <= k) {
                low = mid;
            }
            else {
                high = mid - 1;
            }
        }
        if (low >= i) {
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += lca[j].fast_max(i, low + 1);
            }
            if (sum <= k) {
                int temp = low - i + 1;
                if (temp > ans) {
                    ans = temp;
                    for (int j = 0; j < m; j++) {
                        v[j] = lca[j].fast_max(i, low + 1);
    //                    error(j, i, low);
                    }
                }
            }

        }
    }
//    error(ans);
    for (int i = 0; i < m; i++) {
        printf("%d ", v[i]);
    }
//    error(lca[0].maximum(0, 5));

    return 0;
}


#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;

#define     LL                      long long int
#define     LD                      long double
#define     ULL                     unsigned long long int

#define     pii                     pair<int, int>
#define     ump                     unordered_map
#define     mp                      make_pair
#define     mt                      make_tuple
#define     pb                      push_back
#define     ff                      first
#define     ss                      second
#define     SZ(x)                   (int)x.size()
#define     all(x)                  x.begin(), x.end()
#define     lb(x, y)                lower_bound(all(x), y)
#define     fill2d(arr, a, b, v)    fill(&arr[0][0], &arr[0][0] + a * b, v)
#define     fill3d(arr, a, b, c, v) fill(&arr[0][0], &arr[0][0] + a * b * c, v)
#define     rep(i, begin, end)      for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define     sp(x)                   setprecision(x) << fixed
#define     what_is(x)              cout << #x << " is " << x << endl
//#define     I64                     ll

#define     PI                      acos(-1.0)
#define     EPS                     1e-12
//#define     mx                      200010
#define     S_SIZE                  2000010

const LL inf = 1000000000;
const LL mod = 1000000000 + 7;

inline void IO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
inline int dcmp (LD x) { return x < -EPS ? -1 : (x > EPS); }

template<class T> inline int CHECK(T MASK, int i) { return (MASK >> i) & 1; }
template<class T> inline T ON(T MASK, int i) { return MASK | (T(1) << i); }
template<class T> inline T OFF(T MASK, int i) { return MASK & (~(T(1) << i)); }
template<typename T> inline int CNT(T MASK) {
    if (numeric_limits<T>::digits <= numeric_limits<unsigned int>::digits) return __builtin_popcount(MASK);
    else return __builtin_popcountll(MASK);
}
template<class T> inline int RIGHT(T MASK) { return log2(MASK & -MASK); }

int dx4[] = { 0, 0, -1, +1 }; int dy4[] = { +1, -1, 0, 0 };
int dx8[] = { 1, 1, 0, -1, -1, -1, 0, 1, 0 }; int dy8[] = { 0, 1, 1, 1, 0, -1, -1, -1, 0 };

inline void I(int& a) { scanf("%d", &a); } inline void I(LL& a) { scanf("%I64d", &a); }
inline void I(ULL& a) { scanf("%I64u", &a); } inline void I(char* a) { scanf("%s", a); }
char Iarr[S_SIZE]; inline void I(string& a) { scanf("%s", Iarr); a = Iarr; }
template<typename T, typename... Args>
void I(T& a, Args&... args) { I(a); I(args...); }

inline void OUT(int a) { printf("%d", a); } inline void OUT(LL a) { printf("%I64d", a); }
inline void OUT(const char* a) { printf("%s", a); } inline void OUT(char* a) { printf("%s", a); }
inline void OUT(bool a) { printf("%d", a); } inline void OUT(string a) { rep(it, a.begin(), a.end()) printf("%c", *it); }
inline void OUT(ULL a) { printf("%I64u", a); }
template<typename T, typename... Args>
void OUT(T a, Args... args) { OUT(a); OUT(" "); OUT(args...); }
template<typename... Args>
void O(Args... args) { OUT(args...); OUT("\n"); }

template<typename T1, typename T2>
inline ostream& operator<<(ostream& os, pair<T1, T2> p) { os << "{" << p.first << ", " << p.second << "}"; return os; }
template<typename T>
inline ostream& operator<<(ostream& os, vector<T>& a) { os << "["; for (int i = 0; i < (int)a.size(); i++) { if (i) os << ", "; os << a[i]; } os << "]"; return os; }

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}

// mp.reserve(1024); mp.max_load_factor(0.25);
// head

const int M = 200010; // maximum number of cubes

struct LCA
{
    /* 0 indexed */
    int n;
    int *l;
    int **p;
    int **mn;
    int **mx;
    LL **sum;
    /* parent, min, max, sum */
    int LOG;
    int *logs;
    vector<pii > *g;
    void init1(int nn)
    {
        n = nn;
        l = new int[nn];
        p = new int*[nn];
        mn = new int*[nn];
        mx = new int*[nn];
        sum = new LL*[nn];
        LOG = log2(nn) + 2;
        for (int i = 0; i < nn; i++) {
            p[i] = new int[LOG];
            mn[i] = new int[LOG];
            mx[i] = new int[LOG];
            sum[i] = new LL[LOG];
        }
        g = new vector<pii >[nn];
    }
    void init2(int nn, vector<pii> gg[])
    {
        n = nn;
        l = new int[nn];
        p = new int*[nn];
        mn = new int*[nn];
        mx = new int*[nn];
        sum = new LL*[nn];
        LOG = log2(nn) + 2;
        for (int i = 0; i < nn; i++) {
            p[i] = new int[LOG];
            mn[i] = new int[LOG];
            mx[i] = new int[LOG];
            sum[i] = new LL[LOG];
        }
        g = new vector<pii >[nn];
        for (int i = 0; i < nn; i++) {
            for (auto x : gg[i]) {
                g[i].push_back(x);
            }
        }
    }
    void addEdge(int u, int v, int w)
    {
        g[u].push_back(mp(v, w));
        g[v].push_back(mp(u, w));
    }
    void dfs(int u, int pp, int ll)
    {
        l[u] = ll;
        p[u][0] = pp;
        for (auto x : g[u]) {
            if (x.ff != pp) {
                mn[x.ff][0] = mx[x.ff][0] = sum[x.ff][0] = x.ss;
                dfs(x.ff, u, ll + 1);
            }
        }
    }
    void build()
    {
        dfs(0, -1, 0);
        for (int i = 1; i < LOG; i++) {
            for (int j = 0; j < n; j++) {
                if (p[j][i-1] != -1) {
                    mn[j][i] = min(mn[j][i-1], mn[p[j][i-1]][i-1]);
                    mx[j][i] = max(mx[j][i-1], mx[p[j][i-1]][i-1]);
                    sum[j][i] = sum[j][i-1] + sum[p[j][i-1]][i-1];
                    p[j][i] = p[p[j][i-1]][i-1];
                }
                else {
                    p[j][i] = -1;
                    mn[j][i] = INT_MAX;
                    mx[j][i] = INT_MIN;
                    sum[j][i] = 0;
                }
            }
        }
    }
    int lca(int u, int v)
    {
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                v = p[v][i];
            }
        }
        if (u == v) return u;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                u = p[u][i];
                v = p[v][i];
            }
        }
        return p[u][0];
    }
    int minimum(int u, int v)
    {
        int ret = INT_MAX;
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                ret = min(ret, mn[v][i]);
                v = p[v][i];
            }
        }
        if (u == v) return ret;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                ret = min(ret, mn[u][i]);
                ret = min(ret, mn[v][i]);
                u = p[u][i];
                v = p[v][i];
            }
        }
        ret = min(ret, mn[u][0]);
        ret = min(ret, mn[v][0]);
        return ret;
    }
    int maximum(int u, int v)
    {
        int ret = INT_MIN;
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                ret = max(ret, mx[v][i]);
                v = p[v][i];
            }
        }
        if (u == v) return ret;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                ret = max(ret, mx[u][i]);
                ret = max(ret, mx[v][i]);
                u = p[u][i];
                v = p[v][i];
            }
        }
        ret = max(ret, mx[u][0]);
        ret = max(ret, mx[v][0]);
        return ret;
    }
    LL accumulation(int u, int v)
    {
        LL ret = 0;
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                ret += sum[v][i];
                v = p[v][i];
            }
        }
        if (u == v) return ret;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                ret += sum[u][i];
                ret += sum[v][i];
                u = p[u][i];
                v = p[v][i];
            }
        }
        ret += sum[u][0];
        ret += sum[v][0];
        return ret;
    }
    void fast_g()
    {
        logs = new int[n+1];
        logs[1] = 0;
        for (int i = 2; i <= n; i++)
            logs[i] = logs[i/2] + 1;
    }
    int fast_min(int l, int r)
    {
        int j = logs[r-l+1];
        return min(mn[r][j], mn[l+(1<<j)-1][j]);
    }
    int fast_max(int l, int r)
    {
        int j = logs[r-l];
        return max(mx[r][j], mx[l+(1<<j)-1][j]);
    }
};

int main()
{
    int n, m, k;
    I(n, m, k);
    int a[n][m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            I(a[i][j]);
        }
    }
    LCA lca[m];
    for (int i = 0; i < m; i++) {
        lca[i].init1(n + 1);
        for (int j = 0; j < n; j++) {
            lca[i].addEdge(j, j + 1, a[j][i]);
        }
        lca[i].build();
        lca[i].fast_g();
    }
    int ans = INT_MIN;
    vector<int> v(m);
    for (int i = 0; i < n; i++) {
        int low = i, high = n - 1;
        bool ok = 0;
        while (low < high) {
            int mid = (low + high + 1) / 2;
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += lca[j].fast_max(i, mid + 1);
            }
            if (sum <= k) {
                low = mid;
            }
            else {
                high = mid - 1;
            }
        }
        int sum = 0;
        for (int j = 0; j < m; j++) {
            sum += lca[j].fast_max(i, low + 1);
        }
        if (sum <= k) {
            int temp = low - i + 1;
            if (temp > ans) {
                ans = temp;
                for (int j = 0; j < m; j++) {
                    v[j] = lca[j].fast_max(i, low + 1);
//                    error(j, i, low);
                }
            }

        }
    }
//    error(ans);
    for (int i = 0; i < m; i++) {
        printf("%d ", v[i]);
    }
//    error(lca[0].maximum(0, 5));

    return 0;
}


#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;

#define     LL                      long long int
#define     LD                      long double
#define     ULL                     unsigned long long int

#define     pii                     pair<int, int>
#define     ump                     unordered_map
#define     mp                      make_pair
#define     mt                      make_tuple
#define     pb                      push_back
#define     ff                      first
#define     ss                      second
#define     SZ(x)                   (int)x.size()
#define     all(x)                  x.begin(), x.end()
#define     lb(x, y)                lower_bound(all(x), y)
#define     fill2d(arr, a, b, v)    fill(&arr[0][0], &arr[0][0] + a * b, v)
#define     fill3d(arr, a, b, c, v) fill(&arr[0][0], &arr[0][0] + a * b * c, v)
#define     rep(i, begin, end)      for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define     sp(x)                   setprecision(x) << fixed
#define     what_is(x)              cout << #x << " is " << x << endl
//#define     I64                     ll

#define     PI                      acos(-1.0)
#define     EPS                     1e-12
//#define     mx                      200010
#define     S_SIZE                  2000010

const LL inf = 1000000000;
const LL mod = 1000000000 + 7;

inline void IO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
inline int dcmp (LD x) { return x < -EPS ? -1 : (x > EPS); }

template<class T> inline int CHECK(T MASK, int i) { return (MASK >> i) & 1; }
template<class T> inline T ON(T MASK, int i) { return MASK | (T(1) << i); }
template<class T> inline T OFF(T MASK, int i) { return MASK & (~(T(1) << i)); }
template<typename T> inline int CNT(T MASK) {
    if (numeric_limits<T>::digits <= numeric_limits<unsigned int>::digits) return __builtin_popcount(MASK);
    else return __builtin_popcountll(MASK);
}
template<class T> inline int RIGHT(T MASK) { return log2(MASK & -MASK); }

int dx4[] = { 0, 0, -1, +1 }; int dy4[] = { +1, -1, 0, 0 };
int dx8[] = { 1, 1, 0, -1, -1, -1, 0, 1, 0 }; int dy8[] = { 0, 1, 1, 1, 0, -1, -1, -1, 0 };

inline void I(int& a) { scanf("%d", &a); } inline void I(LL& a) { scanf("%I64d", &a); }
inline void I(ULL& a) { scanf("%I64u", &a); } inline void I(char* a) { scanf("%s", a); }
char Iarr[S_SIZE]; inline void I(string& a) { scanf("%s", Iarr); a = Iarr; }
template<typename T, typename... Args>
void I(T& a, Args&... args) { I(a); I(args...); }

inline void OUT(int a) { printf("%d", a); } inline void OUT(LL a) { printf("%I64d", a); }
inline void OUT(const char* a) { printf("%s", a); } inline void OUT(char* a) { printf("%s", a); }
inline void OUT(bool a) { printf("%d", a); } inline void OUT(string a) { rep(it, a.begin(), a.end()) printf("%c", *it); }
inline void OUT(ULL a) { printf("%I64u", a); }
template<typename T, typename... Args>
void OUT(T a, Args... args) { OUT(a); OUT(" "); OUT(args...); }
template<typename... Args>
void O(Args... args) { OUT(args...); OUT("\n"); }

template<typename T1, typename T2>
inline ostream& operator<<(ostream& os, pair<T1, T2> p) { os << "{" << p.first << ", " << p.second << "}"; return os; }
template<typename T>
inline ostream& operator<<(ostream& os, vector<T>& a) { os << "["; for (int i = 0; i < (int)a.size(); i++) { if (i) os << ", "; os << a[i]; } os << "]"; return os; }

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}

// mp.reserve(1024); mp.max_load_factor(0.25);
// head

const int M = 200010; // maximum number of cubes

struct LCA
{
    /* 0 indexed */
    int n;
    int *l;
    int **p;
    int **mn;
    int **mx;
    LL **sum;
    /* parent, min, max, sum */
    int LOG;
    int *logs;
    vector<pii > *g;
    void init1(int nn)
    {
        n = nn;
        l = new int[nn];
        p = new int*[nn];
        mn = new int*[nn];
        mx = new int*[nn];
        sum = new LL*[nn];
        LOG = log2(nn) + 2;
        for (int i = 0; i < nn; i++) {
            p[i] = new int[LOG];
            mn[i] = new int[LOG];
            mx[i] = new int[LOG];
            sum[i] = new LL[LOG];
        }
        g = new vector<pii >[nn];
    }
    void init2(int nn, vector<pii> gg[])
    {
        n = nn;
        l = new int[nn];
        p = new int*[nn];
        mn = new int*[nn];
        mx = new int*[nn];
        sum = new LL*[nn];
        LOG = log2(nn) + 2;
        for (int i = 0; i < nn; i++) {
            p[i] = new int[LOG];
            mn[i] = new int[LOG];
            mx[i] = new int[LOG];
            sum[i] = new LL[LOG];
        }
        g = new vector<pii >[nn];
        for (int i = 0; i < nn; i++) {
            for (auto x : gg[i]) {
                g[i].push_back(x);
            }
        }
    }
    void addEdge(int u, int v, int w)
    {
        g[u].push_back(mp(v, w));
        g[v].push_back(mp(u, w));
    }
    void dfs(int u, int pp, int ll)
    {
        l[u] = ll;
        p[u][0] = pp;
        for (auto x : g[u]) {
            if (x.ff != pp) {
                mn[x.ff][0] = mx[x.ff][0] = sum[x.ff][0] = x.ss;
                dfs(x.ff, u, ll + 1);
            }
        }
    }
    void build()
    {
        dfs(0, -1, 0);
        for (int i = 1; i < LOG; i++) {
            for (int j = 0; j < n; j++) {
                if (p[j][i-1] != -1) {
                    mn[j][i] = min(mn[j][i-1], mn[p[j][i-1]][i-1]);
                    mx[j][i] = max(mx[j][i-1], mx[p[j][i-1]][i-1]);
                    sum[j][i] = sum[j][i-1] + sum[p[j][i-1]][i-1];
                    p[j][i] = p[p[j][i-1]][i-1];
                }
                else {
                    p[j][i] = -1;
                    mn[j][i] = INT_MAX;
                    mx[j][i] = INT_MIN;
                    sum[j][i] = 0;
                }
            }
        }
    }
    int lca(int u, int v)
    {
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                v = p[v][i];
            }
        }
        if (u == v) return u;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                u = p[u][i];
                v = p[v][i];
            }
        }
        return p[u][0];
    }
    int minimum(int u, int v)
    {
        int ret = INT_MAX;
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                ret = min(ret, mn[v][i]);
                v = p[v][i];
            }
        }
        if (u == v) return ret;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                ret = min(ret, mn[u][i]);
                ret = min(ret, mn[v][i]);
                u = p[u][i];
                v = p[v][i];
            }
        }
        ret = min(ret, mn[u][0]);
        ret = min(ret, mn[v][0]);
        return ret;
    }
    int maximum(int u, int v)
    {
        int ret = INT_MIN;
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                ret = max(ret, mx[v][i]);
                v = p[v][i];
            }
        }
        if (u == v) return ret;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                ret = max(ret, mx[u][i]);
                ret = max(ret, mx[v][i]);
                u = p[u][i];
                v = p[v][i];
            }
        }
        ret = max(ret, mx[u][0]);
        ret = max(ret, mx[v][0]);
        return ret;
    }
    LL accumulation(int u, int v)
    {
        LL ret = 0;
        if (l[u] > l[v])
            swap(u, v);
        int d = l[v] - l[u];
        for (int i = 0; i < LOG; i++) {
            if (CHECK(d, i)) {
                ret += sum[v][i];
                v = p[v][i];
            }
        }
        if (u == v) return ret;
        for (int i = LOG - 1; i >= 0; i--) {
            if (p[u][i] != p[v][i]) {
                ret += sum[u][i];
                ret += sum[v][i];
                u = p[u][i];
                v = p[v][i];
            }
        }
        ret += sum[u][0];
        ret += sum[v][0];
        return ret;
    }
    void fast_g()
    {
        logs = new int[n];
        logs[1] = 0;
        for (int i = 2; i < n; i++)
            logs[i] = logs[i/2] + 1;
    }
    int fast_min(int l, int r)
    {
        int j = logs[r-l+1];
        return min(mn[r][j], mn[l+(1<<j)-1][j]);
    }
    int fast_max(int l, int r)
    {
        int j = logs[r-l];
        //error(l, r, j, mx[r][j], mx[l+(1<<j)][j]);
        return max(mx[r][j], mx[l+(1<<j)][j]);
    }
};

int main()
{
    int aaa;
    int n, m, k;
    I(n, m, k);
    int a[n][m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            I(a[i][j]);
        }
    }
    LCA lca[m];
    for (int i = 0; i < m; i++) {
        lca[i].init1(n + 1);
        for (int j = 0; j < n; j++) {
            lca[i].addEdge(j, j + 1, a[j][i]);
        }
        lca[i].build();
        lca[i].fast_g();
    }
    int ans = INT_MIN;
    vector<int> v(m);
    for (int i = 0; i < n; i++) {
        int low = i, high = n - 1;
        bool ok = 0;
        while (low < high) {
            int mid = (low + high + 1) / 2;
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += lca[j].fast_max(i, mid + 1);
            }
            if (sum <= k) {
                low = mid;
            }
            else {
                high = mid - 1;
            }
        }
        if (low >= i) {
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += lca[j].fast_max(i, low + 1);
            }
            if (sum <= k) {
                int temp = low - i + 1;
                if (temp > ans) {
                    ans = temp;
                    for (int j = 0; j < m; j++) {
                        v[j] = lca[j].fast_max(i, low + 1);
    //                    error(j, i, low);
                    }
                }
            }

        }
    }
//    error(ans);
    for (int i = 0; i < m; i++) {
        printf("%d ", v[i]);
    }
//    error(lca[0].maximum(0, 5));

    return 0;
}