Background
A couple of months ago the web standards project (WaSP) has come up with a test for modern browsers and their CSS implementation called acid2. This test ensures that all the browsers have similar results when it comes to parsing and displaying cascaded style sheet files (CSS) for HTML. Since you want to beat all the other text-based browsers on standard compliance you directly start implementing the CSS capabilities into your favorite text-browser Lynks.
Problem
Your text-browser will be given a set of graphic files and a simplified css-style-sheet. A graphic is defined by a name, height, width and a 2-dimensional array of characters. All characters are to be printed except for the character '.' which denotes a transparent pixel. Here is an example picture:
owl.png 5 7
.-----.
|O...O|
|..v..|
|.<_>.|
.-----.
Given the style-sheet your task is it to produce the graphical result that the browser is supposed to display. A CSS-file is made up from a number of entries where each entry looks like this:
#<id> {
pos-x : <x> px ;
pos-y : <y> px ;
position : <relative = <id of graphic>|absolute> ;
file : <filename> ;
layer : <layer-number> ;
}
The following rules hold for the CSS-entries:
Lines Each CSS-entry will be given on exactly 7 lines as in the input above.
Ordering Each CSS-entry will contain exactly the 5 attributes pos-x, pos-y, position, file and layer, in this order, each attribute on a separate line.
Whitespace There may be zero or more white-spaces (spaces and tabs) at the beginning of lines, at the end of lines or everywhere where the sample above has a space.
Here are the rules for composing the picture:
Background The background is assumed to be black (i.e. just spaces).
Positioning The top left corner of the viewing device is assumed to be x : 0, y : 0. Absolute positioning always is based on this top-left corner. Relative positioning information is always based on the topleft pixel of another graphic. There will not be any circular references between CSS elements. All resulting positions will be zero or greater in x and y.
Layering Graphics with a higher layer number are to be printed after graphics with a lower layer number. Graphics with the same layer number are to be printed in the order they appear in the CSS.