#include using namespace std; int main() { int matrix[4][4]; int extra[20]; int n; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { cin >> matrix[i][j]; } } cin >> n; for (int i = 0; i < n; i++) { cin >> extra[i]; } int merged[36], size = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { merged[size++] = matrix[i][j]; } } for (int i = 0; i < n; i++) { merged[size++] = extra[i]; } for (int i = 0; i < size - 1; i++) { for (int j = i + 1; j < size; j++) { if (merged[i] < merged[j]) { int temp = merged[i]; merged[i] = merged[j]; merged[j] = temp; } } } size = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { matrix[i][j] = merged[size++]; } } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { cout << matrix[i][j] << " "; } cout << endl; } return 0; }