How can I make this code more efficient?(SPAMCLAS)

import sys

def query(input, n, weight, bias):
    ans = input

    for layern in range(n):
        ans = ans * weight[layern] + bias[layern]
    return ans

def read():
    return sys.stdin.readline().strip()

def readTestCase():

    [n, minX, maxX] = read().split(' ')

    n = int(n)
    minX = int(minX)
    maxX = int(maxX)
    weights = []
    biases = []
    for j in range(n):
        a = read().split(' ')
        weights.append(int(a[0]))
        biases.append(int(a[1]))




    spammers = 0
    nonspammers = 0
    for i in range(minX, maxX+1):



        y = query(i, n, weights, biases)
        if y % 2 == 0:

            nonspammers += 1
        else:

            spammers+=1

    return[nonspammers, spammers]
T = int(read())
for i in range(T):
    print(readTestCase())

This is for the Problem SPAMCLAS.(Python 3.5)
I am getting an overtime error.
How can I optimize this code?

According to the constraints given, 1 <= minX, maxX <= 1e9 and 1 <= N <= 1e5.

Your solution has complexity O(T.(maxX - minX).N) whose value is around 1e(1 + 9 + 5) or 1e15; much much more than 1e8.

Hence there is absolutely no chance for this algorithm to complete within the time limit…

Check the editorial here if you face problem.

Thank you, I am not able to understand the editorial solution. If possible, please can you explain me. AGS Developers
Web Development Company
Hire Volusion Developers
Volusion Customization Services
eCommerce Product Data Entry Services
eCommerce Data Entry Services
Shopify Development
Volusion Development
Magento Development
BigCommerce Development
Wordpress Development
Hire Volusion Developers
Volusion Customization Services
eCommerce Product Data Entry Services
Customized Tee Shirts
Create Custom Shirts
SuperStupidFresh
Detox And Cleanse Reviews
Alpha Prime Elite
Garcinia Pure Pro
Weight Loss That Works
Pure Asian Garcinia
Buy Garcinia Cambogia
Hair Loss Treatment For Men
Muscle Building Foods
Skin Rejuvenator
Anti Aging Device

Thank you, I am not able to understand the editorial solution.
If possible, please can you explain me.

What you can try is to contact the professional team of Magento developers for any magento website cost question