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

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

i = A("i")
f = B("f")
j = A("j")
e = A("e")
k = B("k")
m = B("m")
d = B("d")
c = B("c")
b = A("b")
n = B("n")

i.y = c
f.q = d
f.z = d
j.y = n
e.y = c
k.q = m
k.z = m
m.q = c
m.z = c
d.q = c
d.z = n
c.q = m
c.z = d
b.y = d
n.q = k
n.z = m
assert n.q.z.z.q.z.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

i = A("i")
f = B("f")
j = A("j")
e = A("e")
k = B("k")
m = B("m")
d = B("d")
c = B("c")
b = A("b")
n = B("n")

i.y = c
f.q = d
f.z = d
j.y = n
e.y = c
k.q = m
k.z = m
m.q = c
m.z = c
d.q = c
d.z = n
c.q = m
c.z = d
b.y = d
n.q = k
n.z = m
assert n.q.z.z.q.z.z.q.txt == "c"