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

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

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

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

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

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

h.z = e
h.r = l
m.y = b
m.p = b
i.z = m
i.r = l
k.z = e
k.r = i
f.z = b
f.r = k
b.y = e
b.p = m
d.y = b
d.p = m
l.z = e
l.r = i
n.z = d
n.r = h
e.y = b
e.p = m
assert b.p.p.p.y.p.p.txt == "b"