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

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

l = A("l")
f = B("f")
n = A("n")
m = B("m")
k = B("k")
a = B("a")
g = A("g")
i = B("i")
d = A("d")

l.z = g
l.t = n
f.o = k
f.w = a
n.z = g
n.t = d
m.o = a
m.w = k
k.o = i
k.w = i
a.o = i
a.w = k
g.z = l
g.t = d
i.o = k
i.w = m
d.z = l
d.t = g
assert g.t.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: A = None
        self.txt = txt

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

l = A("l")
f = B("f")
n = A("n")
m = B("m")
k = B("k")
a = B("a")
g = A("g")
i = B("i")
d = A("d")

l.z = g
l.t = n
f.o = k
f.w = a
n.z = g
n.t = d
m.o = a
m.w = k
k.o = i
k.w = i
a.o = i
a.w = k
g.z = l
g.t = d
i.o = k
i.w = m
d.z = l
d.t = g
assert g.t.z.z.z.z.z.txt == "l"