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

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

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

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

k = A("k")
e = B("e")
c = C("c")
i = D("i")

k.t = i
e.q = i
e.y = i
e.s = c
c.p = i
c.t = k
i.q = c
i.x = c
assert k.t.x.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

k = A("k")
e = B("e")
c = C("c")
i = D("i")

k.t = i
e.q = i
e.y = i
e.s = c
c.p = i
c.t = k
i.q = c
i.x = c
assert k.t.x.t.t.txt == "i"