#T769. 组队问题

组队问题

Description

OJ has introduced many new features in version 3.0, including the team functionality. However, since this is a new feature and the developers' skills are not yet mature, there may be up to n bugs during usage. Therefore, once a bug is discovered, administrators recommend that COIers report it to the feedback email (question@codesonline.cn).

Due to the large number of people submitting feedback and the inability of OJ team members to properly divide tasks, administrators suggest forming teams to handle the feedback.

There are two ways to form teams:     Type 1: 3 members + 1 email receiver
    Type 2: 10 members + 4 email receivers

Input Format

The input consists of a single line with two numbers, nn and mm, representing the number of members and the number of email receivers, respectively.

Output Format

The output consists of two lines:

  • The first line: Output the minimum number of teams formed (while minimizing the remaining number of people).
  • The second line: Output the remaining number of people (output 0 if there are no remaining people).

If it is impossible to form any teams, output 0.

Example 1

Input:

10 4

Output:

1
0

Explanation:
Form 1 team of Type 2 (10 members + 4 email receivers). No members or email receivers are left.

Example 2

Input:

13 5

Output:

2
1

Explanation:
Form 1 team of Type 1 (3 members + 1 email receiver) and 1 team of Type 2 (10 members + 4 email receivers). This uses up 13 members and 5 email receivers, leaving 0 remaining.

Example 3

Input:

2 1

Output:

0

Explanation:
Neither team type can be formed with the given numbers.

Constraints

  • 1n,m1061 \leq n, m \leq 10^6
3 1
1
0
13 6
2
1

Hint

Data Range:
    mn60m≤n≤60

Source

Original problem from CodesOnline