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

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

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

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

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

b.t = n
d.u = n
d.s = n
d.x = n
d.p = i
i.y = k
n.x = i
n.y = b
n.t = b
n.p = d
k.y = i
assert k.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

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

b.t = n
d.u = n
d.s = n
d.x = n
d.p = i
i.y = k
n.x = i
n.y = b
n.t = b
n.p = d
k.y = i
assert k.y.y.y.y.txt == "k"