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

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

g = A("g")
j = B("j")
k = B("k")
l = A("l")
a = A("a")
d = A("d")
i = B("i")
h = B("h")
c = A("c")
n = B("n")

g.y = n
j.o = n
j.z = n
k.o = j
k.z = i
l.y = k
a.y = h
d.y = h
i.o = h
i.z = h
h.o = n
h.z = i
c.y = j
n.o = j
n.z = h
assert g.y.o.z.z.o.o.z.z.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

g = A("g")
j = B("j")
k = B("k")
l = A("l")
a = A("a")
d = A("d")
i = B("i")
h = B("h")
c = A("c")
n = B("n")

g.y = n
j.o = n
j.z = n
k.o = j
k.z = i
l.y = k
a.y = h
d.y = h
i.o = h
i.z = h
h.o = n
h.z = i
c.y = j
n.o = j
n.z = h
assert g.y.o.z.z.o.o.z.z.o.o.txt == "j"