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

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

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

b = A("b")
f = B("f")
k = C("k")
a = D("a")

b.u = a
b.r = k
b.q = k
b.s = f
f.u = b
f.y = b
k.t = a
a.s = k
assert f.y.r.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.r: C = None
        self.s: B = None
        self.q: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

b = A("b")
f = B("f")
k = C("k")
a = D("a")

b.u = a
b.r = k
b.q = k
b.s = f
f.u = b
f.y = b
k.t = a
a.s = k
assert f.y.r.t.s.txt == "k"