Please help in solving this problem , am i unable to pass test case

[1:24 PM, 3/23/2020] Shivam Durani: You are asked q queries each of which can be of type 1 or type 2 Type 1 : Report the area of square of side S. Type 2 : Report the area of rectangle of sides L and R.
Input
The first line of the input contains single integer Q.
Next Q line contains the queries.
Each query first contains type of query
if query is of type one you are given a single integer S
if query is of type two you are given two integers L and R

Constraints
1 <= Q <= 25
1 <= T <= 2
1 <= S,L,R <= 1000
Output
Output Q line each containing answer to the asked query.
[1:24 PM, 3/23/2020] Shivam Durani: please help me solving this

import java.io.*; // for handling input/output

import java.util.*; // contains Collections framework

import java.lang.*;

// don’t change the name of this class

// you can add inner classes if needed

class Main {

public static void main (String[] args) {

    Scanner scan = new Scanner(System.in);

    int Q = scan.nextInt();

    int T,S,L,R;

    int as=0, ar=0; 

    if(Q>=1 && Q<=25){

        for(int i=1; i<=Q; i++){

            T = scan.nextInt();

            if(T==1){

                S = scan.nextInt();

                if(S>=1 && S<=1000){

                    as = S*S;

                }

            }else if(T==2){

                L = scan.nextInt();

                R = scan.nextInt();

                if(L>=1 && R>=1 && L<=1000 && R<=1000){

                    ar = L*R;

                }

            }

        }

        System.out.println(ar);

        System.out.println(as);

    }

}

}

this can be done with small change in previous code as:

class Main {

public static void main (String[] args) {

    Scanner scan = new Scanner(System.in);

    int Q = scan.nextInt();

    int T,S,L,R;

    int as=0, ar=0; 

    if(Q>=1 && Q<=25){

        for(int i=1; i<=Q; i++){

            T = scan.nextInt();

            if(T==1){

                S = scan.nextInt();

                if(S>=1 && S<=1000){

                    as = S*S;

                    System.out.println(as);

                }

            }else if(T==2){

                L = scan.nextInt();

                R = scan.nextInt();

                if(L>=1 && R>=1 && L<=1000 && R<=1000){

                    ar = L*R;

                    System.out.println(ar);

                }

            }

        }

    }

}

}