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

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

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

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

j = A("j")
d = B("d")
a = C("a")
c = D("c")

j.q = c
j.u = a
j.y = a
d.t = c
a.u = j
c.r = a
assert d.t.r.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.u: C = None
        self.y: C = None
        self.txt = txt

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

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

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

j = A("j")
d = B("d")
a = C("a")
c = D("c")

j.q = c
j.u = a
j.y = a
d.t = c
a.u = j
c.r = a
assert d.t.r.u.q.txt == "c"