a) 2 white and 2 black cats are sitting on the line. The sum of distances from the white cats to one black cat is 4, to the other black cat is 8. The sum of distances from the black cats to one white cat is 3, to the other white cat is 9. What cats are sitting on the edges?

b) 2 white and 3 black cats are sitting on the line. The sum of distances from the white cats to one black cat is 11, to another black cat is 7 and to the third black cat is 9. The sum of distances from the black cats to one white cat is 12, to the other white cat is 15. What cats are sitting on the edges?

[size=85](Kyiv mathematical festival 2014)[/size]
a) Let \( |W_1B_1| = a_1 \), \( |W_2B_1| = a_2 \), \( |W_1B_2| = b_1 \), and \( |W_2B_2| = b_2 \).

We are given the following conditions:
1. \( a_1 + a_2 = 4 \)
2. \( b_1 + b_2 = 8 \)
3. \( b_1 + a_1 = 9 \)
4. \( b_2 + a_2 = 3 \)

From these conditions, we can derive the following steps:

1. Subtract equation (4) from equation (3):
   \[
   (b_1 + a_1) - (b_2 + a_2) = 9 - 3
   \]
   \[
   b_1 + a_1 - b_2 - a_2 = 6
   \]

2. Substitute \( a_1 + a_2 = 4 \) into the equation:
   \[
   b_1 - b_2 = 6
   \]

3. From equation (3), solve for \( b_1 \):
   \[
   b_1 = 9 - a_1
   \]

4. From equation (4), solve for \( b_2 \):
   \[
   b_2 = 3 - a_2
   \]

5. Substitute \( b_1 = 9 - a_1 \) and \( b_2 = 3 - a_2 \) into \( b_1 - b_2 = 6 \):
   \[
   (9 - a_1) - (3 - a_2) = 6
   \]
   \[
   9 - a_1 - 3 + a_2 = 6
   \]
   \[
   6 - a_1 + a_2 = 6
   \]
   \[
   -a_1 + a_2 = 0
   \]
   \[
   a_1 = a_2
   \]

6. Since \( a_1 + a_2 = 4 \) and \( a_1 = a_2 \):
   \[
   2a_1 = 4
   \]
   \[
   a_1 = 2
   \]
   \[
   a_2 = 2
   \]

7. Substitute \( a_1 = 2 \) into \( b_1 = 9 - a_1 \):
   \[
   b_1 = 9 - 2 = 7
   \]

8. Substitute \( a_2 = 2 \) into \( b_2 = 3 - a_2 \):
   \[
   b_2 = 3 - 2 = 1
   \]

Since \( b_1 = 7 \) is greater than the other distances, the extremes are \( W_1 \) (first white cat) and \( B_2 \) (second black cat).

The final answer is \( \boxed{ W_1 } \) and \( B_2 \).