import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.range;

void main() {
    int n = readln.chomp.to!int;
    int[][] diploma;
    for (int i = 0; i < 3; i++) {
        diploma ~= readln.chomp.split.map!(to!int).array;
    }

    int dip_1 = min(diploma[0][1], n - (diploma[1][0] + diploma[2][0]));
    n -= dip_1;
    int dip_2 = min(diploma[1][1], n - diploma[2][0]);
    int dip_3 = n - dip_2;
    writeln(dip_1, " ", dip_2, " ", dip_3);
}