Script that handles any given query