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

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

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

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

d = A("d")
a = B("a")
b = C("b")
n = D("n")
i = C("i")
k = D("k")

d.t = n
d.q = b
a.r = i
a.q = b
a.o = n
b.u = a
b.q = a
b.y = a
b.o = k
n.u = k
n.r = d
n.y = d
n.x = d
i.u = a
i.q = a
i.y = a
i.o = k
k.u = n
k.r = d
k.y = d
k.x = d
assert i.o.x.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.q: C = None
        self.txt = txt

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

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

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

d = A("d")
a = B("a")
b = C("b")
n = D("n")
i = C("i")
k = D("k")

d.t = n
d.q = b
a.r = i
a.q = b
a.o = n
b.u = a
b.q = a
b.y = a
b.o = k
n.u = k
n.r = d
n.y = d
n.x = d
i.u = a
i.q = a
i.y = a
i.o = k
k.u = n
k.r = d
k.y = d
k.x = d
assert i.o.x.q.u.txt == "a"