class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.u: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.p: B = None
        self.txt = txt

g = A("g")
i = B("i")
b = B("b")
a = A("a")
n = B("n")
m = A("m")
j = B("j")
f = A("f")
c = A("c")
l = A("l")

g.z = i
g.u = n
i.u = j
i.p = j
b.u = j
b.p = n
a.z = n
a.u = j
n.u = b
n.p = j
m.z = b
m.u = n
j.u = n
j.p = n
f.z = n
f.u = i
c.z = i
c.u = j
l.z = b
l.u = b
assert g.z.p.u.p.p.u.p.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.u: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.p: B = None
        self.txt = txt

g = A("g")
i = B("i")
b = B("b")
a = A("a")
n = B("n")
m = A("m")
j = B("j")
f = A("f")
c = A("c")
l = A("l")

g.z = i
g.u = n
i.u = j
i.p = j
b.u = j
b.p = n
a.z = n
a.u = j
n.u = b
n.p = j
m.z = b
m.u = n
j.u = n
j.p = n
f.z = n
f.u = i
c.z = i
c.u = j
l.z = b
l.u = b
assert g.z.p.u.p.p.u.p.u.u.txt == "j"