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

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

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.o: A = None
        self.q: C = None
        self.z: D = None
        self.txt = txt

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

f = A("f")
l = B("l")
b = C("b")
i = D("i")
k = C("k")
a = D("a")
g = A("g")
n = D("n")
e = D("e")
m = B("m")

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

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

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.o: A = None
        self.q: C = None
        self.z: D = None
        self.txt = txt

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

f = A("f")
l = B("l")
b = C("b")
i = D("i")
k = C("k")
a = D("a")
g = A("g")
n = D("n")
e = D("e")
m = B("m")

f.z = g
l.r = n
b.t = l
b.o = f
b.q = k
b.z = n
i.o = m
i.u = f
i.w = g
i.x = l
k.t = l
k.o = f
k.q = b
k.z = a
a.o = l
a.u = g
a.w = f
a.x = m
g.z = f
n.o = m
n.x = m
n.u = g
n.w = g
e.o = m
e.x = m
e.u = g
e.w = g
m.r = i
assert l.r.x.r.w.z.z.z.z.z.z.txt == "g"