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

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

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

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

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

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

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

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

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

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

b.t = d
b.u = k
b.r = a
k.x = b
k.y = l
k.o = d
l.x = b
d.o = a
d.u = l
a.t = d
a.u = k
a.r = b
assert a.r.t.u.x.t.txt == "d"