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

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: B = None
        self.q: C = None
        self.s: A = None
        self.u: A = None
        self.txt = txt

l = A("l")
i = B("i")
f = C("f")
m = D("m")
d = D("d")
h = B("h")
e = C("e")
n = D("n")
c = D("c")
k = C("k")

l.z = i
l.o = e
l.q = f
i.v = h
f.r = h
f.v = l
m.x = h
m.q = f
m.s = l
m.u = l
d.x = h
d.q = e
d.s = l
d.u = l
h.v = i
e.r = h
e.v = l
n.x = i
n.q = f
n.s = l
n.u = l
c.x = h
c.q = k
c.s = l
c.u = l
k.r = i
k.v = l
assert h.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.o: C = None
        self.q: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: B = None
        self.q: C = None
        self.s: A = None
        self.u: A = None
        self.txt = txt

l = A("l")
i = B("i")
f = C("f")
m = D("m")
d = D("d")
h = B("h")
e = C("e")
n = D("n")
c = D("c")
k = C("k")

l.z = i
l.o = e
l.q = f
i.v = h
f.r = h
f.v = l
m.x = h
m.q = f
m.s = l
m.u = l
d.x = h
d.q = e
d.s = l
d.u = l
h.v = i
e.r = h
e.v = l
n.x = i
n.q = f
n.s = l
n.u = l
c.x = h
c.q = k
c.s = l
c.u = l
k.r = i
k.v = l
assert h.v.v.v.v.v.v.txt == "h"