I'm trying to solve this problem: <https://www.hackerrank.com/tests/2h92ckdchlg/>
(My job is to count how many frequencies value fit in all the intervals of filterRanges)

But I'm facing an "Terminated due to timeout" after 10 seconds of code execution.

My solution is this one:

```
def countSignals(frequencies, ranges):
    ranges = [range(i[0], i[1] + 1) for i in ranges]
    return sum(1 if all(f in r for r in ranges) else 0 for f in frequencies)

if __name__ == '__main__':

    frequencies_count = int(input().strip())

    frequencies = []

    for _ in range(frequencies_count):
        frequencies_item = int(input().strip())
        frequencies.append(frequencies_item)

    filterRanges_rows = int(input().strip())
    filterRanges_columns = int(input().strip())

    filterRanges = []

    for _ in range(filterRanges_rows):
        filterRanges.append(list(map(int, input().rstrip().split())))

    result = countSignals(frequencies, filterRanges)

    print(result)

```

I can only edit the countSignal function!

How my code runs:

I receive a number, equivalent to len(frequencies). After that, I get each one of the elements that will compose the frequencies list. Then I receive len(filterRanges) and the dimension of each one of the lists that compose the matrix filterRanges. At the end, I get the values that compose each list.

Input example:

```
5 #-> len(frequencies)
20 #-> frequencies[0]
5 #-> frequencies[1]
6 #-> frequencies[2]
7 #-> frequencies[3]
12# -> frequencies[4]
3 #-> len(filterRanges) -> filterRanges is a matrix
2 #-> lenght of the lists that compose filterRanges
10 20 #-> filterRanges[0] = [10,20]
5 15 #-> filterRanges[1] = [5,15]
5 30 #-> filterRanges[2] = [5,30]

```

In this case, for example, it would return 1, because only "12" fits all the intervals.

I've been through 12 of 15 tests with this code, getting timeout error on the last 3. How can I optimize my code so I'm able to pass in all of these tests?

Thanks ! :)