This page is still under construction.

Parts of this page are still being built. What you see may change.

Team Programming Contest

Time limit1sMemory limit128 MB

Summary
Each member-computer can solve a sequence of problems they are able to solve, each taking r minutes; maximize the number solved within t minutes and minimize total penalty.
Level

Medium7 of 10

Topics
Greedy, Sorting, Implementation, Binary search
Solved
No attempts yet

Problem

Bartie and his teammates take part in a team programming contest. Each team has nn members and is given nn computers. The contest lasts tt minutes, during which the members try to solve mm programming problems.

Penalties are added up as follows: finishing a problem ss minutes after the start of the contest costs ss penalty points. A team that solves more problems always ranks higher; among teams that solve the same number of problems, the one with the smaller total penalty ranks higher.

Before the contest Bartie reads all of the statements and knows his team so well that he can tell exactly which member is able to solve which problem. Any member who is able to solve a problem needs exactly rr minutes of computer time to finish it. Each member has one computer and can work on at most one problem at a time, so a member who takes on several problems solves them one after another, back to back.

Given, as known at the start of the contest, which member is able to solve which problem, find the best result the team can reach: the greatest number of problems it can solve and, for that number of problems, the smallest possible total penalty.

Input

The first line contains five integers nn, mm, rr, tt, and kk (1≤n,m≤5001 \le n, m \le 500, 1≤r,t≤1061 \le r, t \le 10^6), separated by single spaces: the number of members on the team, the number of problems, the time one member needs to solve one problem, the length of the contest, and the number of member-problem pairs that follow.

Each of the next kk lines contains two integers aa and bb (1≤a≤n1 \le a \le n, 1≤b≤m1 \le b \le m), separated by a single space, meaning that member aa is able to solve problem bb. Every such pair appears at most once.

Output

Print one line with two integers separated by a single space: zz, the greatest number of problems the team can solve, and pp, the smallest total penalty with which those zz problems can be solved.

If the team cannot solve any problem, print 0 0.

Examples1

  1. Example 1

    Input
    2 4 3 15 4
    1 1
    2 3
    1 4
    1 3
    
    Expected output
    3 12