function y = mmg_step(r,lower,upper,AA,PP)

m = length(AA);

rr = cell(1,m);
vv = cell(1,m);
ll = cell(1,m);
uu = cell(1,m);

rr{end} = r;
ll{end} = lower;
uu{end} = upper;

for k=m:-1:2
    vv{k} = pgs_inc(AA{k}, rr{k}, ll{k}, uu{k});
    
    rr{k} = rr{k} - AA{k}*vv{k};
    ll{k} = ll{k} - vv{k};
    uu{k} = uu{k} - vv{k};

    rr{k-1} = PP{k-1}'*rr{k};
    ll{k-1} = zeros(size(PP{k-1},2),1);
    uu{k-1} = zeros(size(PP{k-1},2),1);
    for i=1:size(PP{k-1},2)
        jj = find(PP{k-1}(:,i));
        ll{k-1}(i) = max([ll{k}(jj); -inf]);
        uu{k-1}(i) = min([uu{k}(jj); inf]);
    end
end

vv{1} = pgs_inc(AA{1}, rr{1}, ll{1}, uu{1});
%rr{1} = rr{1} - AA{1}*vv{1};

for k = 2:m
    vCoarse = PP{k-1}*vv{k-1};
    vv{k} = vv{k} + vCoarse;
end
y = vv{m};

