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

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

b = A("b")
m = B("m")
f = B("f")
n = B("n")
l = A("l")
i = B("i")
k = A("k")
d = B("d")
g = B("g")
h = A("h")

b.z = g
b.y = i
m.u = f
f.u = d
n.u = f
l.z = n
l.y = f
i.u = d
k.z = d
k.y = m
d.u = f
g.u = d
h.z = m
h.y = f
assert h.y.u.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.y: B = None
        self.txt = txt

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

b = A("b")
m = B("m")
f = B("f")
n = B("n")
l = A("l")
i = B("i")
k = A("k")
d = B("d")
g = B("g")
h = A("h")

b.z = g
b.y = i
m.u = f
f.u = d
n.u = f
l.z = n
l.y = f
i.u = d
k.z = d
k.y = m
d.u = f
g.u = d
h.z = m
h.y = f
assert h.y.u.u.u.u.u.u.u.txt == "d"