{"task": {"agent_timeout": 600, "task": "925", "verifier_timeout": 7200, "instruction": "Please implement a Python 3 solution to the below problem.\nReason through the problem and:\n1. Restate the problem in plain English\n2. Conceptualize a solution first in plain English\n3. Write a pseudocode solution\n4. Save your solution as solution.py\nNo outside libraries are allowed.\n\n[BEGIN PROBLEM]\nBessie and Farmer John enjoy goat kart racing. The idea is very similar to\nGo-Kart racing that others enjoy, except the karts are pulled by goats and the\ntrack is made from nearby farmland. The farmland consists of $N$ meadows and $M$\nroads, each connecting a pair of meadows.\n\nBessie wants to make a course from nearby farms.  A farm is a subset of two or\nmore meadows within which every meadow can reach every other meadow along a \nunique sequence of roads.  \n\nThe nearby farmland may contain multiple farms. Suppose there are $K$ farms.\nBessie would like to make a goat kart loop by connecting all $K$ farms by adding\n$K$ roads of length $X$. Each farm should be visited exactly once and at least\none road must be traversed inside each farm.\n\nTo make the course interesting for racers, the total length of the track should\nbe at least $Y$. Bessie wants to know the sum, over all such interesting tracks,\nof the total track lengths.  A track is different from another if there are two\nmeadows which are adjacent (after adding the roads between farms) in one track\nbut not the other. Please note that only the roads chosen matter, and not the\ndirection the goat karts will travel along those roads.\n\nINPUT FORMAT:\nThe first line of input contains $N$, $M$, $X$, and $Y$ where\n$1 \\leq N \\leq 1500$, $1 \\leq M \\leq N-1$, and $0 \\leq X, Y \\leq 2500$.\n\nEach of the $M$ following lines describe roads. The lines are of the form: $A_i$\n$B_i$ $D_i$, meaning that meadows $A_i$ and $B_i$ are connected with a road of\ninteger length $D_i$ ($1 \\leq A_i, B_i \\leq N$, $0 \\leq D_i \\leq 2500$).  Each\nmeadow is incident to at least one road, and there are no cycles of roads.\n\nIn at least 70% of the test cases, it is also guaranteed that $N \\leq 1000$ and $Y \\leq 1000$.\n\nOUTPUT FORMAT:\nOutput a single integer, giving the sum of track lengths over all interesting\ntracks. As the sum of track lengths can be quite large, print the sum of lengths\nmodulo\n$10^9+7$.\n\nSAMPLE INPUT:\n5 3 1 12\n1 2 3\n2 3 4\n4 5 6\nSAMPLE OUTPUT: \n54\n\nThis example has 6 possible tracks\n\n1 --> 2 --> 4 --> 5 --> 1         (length 11)\n\n1 --> 2 --> 5 --> 4 --> 1         (length 11)\n\n2 --> 3 --> 4 --> 5 --> 2         (length 12)\n\n2 --> 3 --> 5 --> 4 --> 2         (length 12)\n\n1 --> 2 --> 3 --> 4 --> 5 --> 1   (length 15)\n\n1 --> 2 --> 3 --> 5 --> 4 --> 1   (length 15)\n\nThe answer is $12+12+15+15=54$, adding up only the tracks where the length is at\nleast $12$.\n\nNote that for this problem, the standard time limit is increased to 3 seconds\nper test case (6 seconds per case for Java and Python).\n\n\nProblem credits: Matt Fontaine\n\n[END PROBLEM]\n", "memory": "2048m", "runnable": false, "difficulty": "medium", "language": "", "cpus": 1, "instruction_truncated": false, "category": "python_programming", "compose": false, "has_solution": true, "oracle": null, "docker_image": "", "taskset": "usaco", "tags": ["python", "programming", "usaco"]}, "runs": []}