<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create_query(key, person, event=None, timestamp=None, identity=None, properties=None):
 """Build and encode query string. :param key: API key for product, found on the "KISSmetrics Settings". :param person: individual performing `event` :param event: event name that was performed :param timestamp: when `event` was performed; optional for back-dating :param identity: individual to alias to `person` :param properties: any additional data to include :type properties: dict :returns: URL encoded string representing query string :rtype: str .. note:: When a ``timestamp`` is provided, the ``TIME_FLAG_KEY`` will be set to ``1`` and included. """

    if properties is None:
        properties = {}

    query_dict = {KEY_KEY: key, PERSON_KEY: person}
    if timestamp:
        query_dict[TIME_FLAG_KEY] = 1
        query_dict[TIME_KEY] = int(timestamp)
    if event:
        query_dict[EVENT_NAME_KEY] = event
    if identity:
        query_dict[ALIAS_KEY] = identity
    query_dict.update(properties)
    return urlencode(query_dict)