output_description: If we have x hours until New Year at M o'clock on 30th, December, print x.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      M
attempt: # !/usr/bin/env python
  # -*- coding: utf-8 -*-
  import math
  
  
  def generate_prime(p_max):
      prime = set([2])
      for i in range(3, p_max + 1):
          for p in prime:
              if i % p == 0:
                  break
              if p > int(math.sqrt(i)):
                  prime.add(i)
                  break
      return prime
  
  
  def main():
      prime = generate_prime(10**5)
      prime2 = set()
      for p in prime:
          if (p + 1) / 2 in prime:
              prime2.add(p)
      ans = [0] * (10**5 + 1)
      for i in range(1, 10**5 + 1):
          if i in prime2:
              ans[i] = ans[i - 1] + 1
          else:
              ans[i] = ans[i - 1]
  
      q = int(input())
      queries = [[int(i) for i in input().split()] for _ in range(q)]
      for query in queries:
          print(ans[query[1]] - ans[query[0] - 1])
  
  
  if __name__ == "__main__":
      main()
  
problem_description: Statement
  
  How many hours do we have until New Year at M o'clock (24-hour notation) on
  30th, December?
samples: [{"input": "21", "output": "27\n    \n\nWe have 27 hours until New Year at 21 o'clock on 30th, December.\n\n* * *"}, {"input": "12", "output": "36"}]