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

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

d = A("d")
c = B("c")
l = B("l")
b = B("b")
n = A("n")
g = A("g")
h = A("h")
f = A("f")

d.z = c
d.r = b
c.w = b
c.z = l
l.w = c
l.z = c
b.w = l
b.z = l
n.z = l
n.r = l
g.z = c
g.r = b
h.z = l
h.r = b
f.z = c
f.r = b
assert f.z.w.z.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: B = None
        self.txt = txt

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

d = A("d")
c = B("c")
l = B("l")
b = B("b")
n = A("n")
g = A("g")
h = A("h")
f = A("f")

d.z = c
d.r = b
c.w = b
c.z = l
l.w = c
l.z = c
b.w = l
b.z = l
n.z = l
n.r = l
g.z = c
g.r = b
h.z = l
h.r = b
f.z = c
f.r = b
assert f.z.w.z.w.w.txt == "b"