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

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

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

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

c = A("c")
k = B("k")
j = C("j")
h = D("h")
m = C("m")
d = C("d")
l = C("l")
n = D("n")

c.t = d
k.w = c
k.s = c
k.x = c
k.r = l
j.x = n
j.z = d
j.w = c
j.u = l
h.o = c
m.x = h
m.z = d
m.w = c
m.u = j
d.x = n
d.z = l
d.w = c
d.u = j
l.x = n
l.z = j
l.u = j
l.w = c
n.o = c
assert k.s.t.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

c = A("c")
k = B("k")
j = C("j")
h = D("h")
m = C("m")
d = C("d")
l = C("l")
n = D("n")

c.t = d
k.w = c
k.s = c
k.x = c
k.r = l
j.x = n
j.z = d
j.w = c
j.u = l
h.o = c
m.x = h
m.z = d
m.w = c
m.u = j
d.x = n
d.z = l
d.w = c
d.u = j
l.x = n
l.z = j
l.u = j
l.w = c
n.o = c
assert k.s.t.w.t.txt == "d"