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

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

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

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

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

f.u = c
f.w = c
f.q = d
f.z = d
d.y = k
c.p = d
c.u = d
c.w = f
c.x = f
l.t = d
l.z = d
l.s = d
l.o = h
e.u = c
e.w = c
e.q = d
e.z = d
k.t = d
k.z = d
k.s = d
k.o = f
h.u = c
h.w = c
h.q = d
h.z = d
assert d.y.z.y.z.y.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: B = None
        self.z: B = None
        self.w: C = None
        self.txt = txt

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

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

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

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

f.u = c
f.w = c
f.q = d
f.z = d
d.y = k
c.p = d
c.u = d
c.w = f
c.x = f
l.t = d
l.z = d
l.s = d
l.o = h
e.u = c
e.w = c
e.q = d
e.z = d
k.t = d
k.z = d
k.s = d
k.o = f
h.u = c
h.w = c
h.q = d
h.z = d
assert d.y.z.y.z.y.z.y.txt == "k"