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

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

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

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

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

a.y = k
d.r = a
d.t = a
d.u = a
d.o = k
f.o = k
f.q = d
f.t = e
f.s = a
k.y = l
k.w = a
e.o = k
e.q = d
e.t = f
e.s = a
l.r = a
l.t = a
l.u = a
l.o = k
assert a.y.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

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

a.y = k
d.r = a
d.t = a
d.u = a
d.o = k
f.o = k
f.q = d
f.t = e
f.s = a
k.y = l
k.w = a
e.o = k
e.q = d
e.t = f
e.s = a
l.r = a
l.t = a
l.u = a
l.o = k
assert a.y.w.y.txt == "k"