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

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

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

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

b = A("b")
j = B("j")
c = C("c")
i = D("i")

b.t = c
j.y = b
c.u = j
c.x = i
i.u = b
i.t = c
assert c.u.y.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

b = A("b")
j = B("j")
c = C("c")
i = D("i")

b.t = c
j.y = b
c.u = j
c.x = i
i.u = b
i.t = c
assert c.u.y.t.x.txt == "i"