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

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

g = A("g")
m = B("m")
n = A("n")
a = A("a")
j = A("j")
e = B("e")
l = A("l")
f = B("f")
b = A("b")
k = B("k")

g.y = l
m.z = j
n.y = b
a.y = b
j.y = b
e.z = g
l.y = g
f.z = b
b.y = n
k.z = a
assert n.y.y.y.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

g = A("g")
m = B("m")
n = A("n")
a = A("a")
j = A("j")
e = B("e")
l = A("l")
f = B("f")
b = A("b")
k = B("k")

g.y = l
m.z = j
n.y = b
a.y = b
j.y = b
e.z = g
l.y = g
f.z = b
b.y = n
k.z = a
assert n.y.y.y.y.y.y.y.y.y.txt == "b"