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

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

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

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

j = A("j")
g = B("g")
i = C("i")
h = D("h")

j.z = i
j.y = g
g.z = h
g.y = h
g.u = j
g.t = j
i.y = j
h.x = i
h.y = g
h.v = j
assert h.y.t.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.y: B = None
        self.txt = txt

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

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

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

j = A("j")
g = B("g")
i = C("i")
h = D("h")

j.z = i
j.y = g
g.z = h
g.y = h
g.u = j
g.t = j
i.y = j
h.x = i
h.y = g
h.v = j
assert h.y.t.y.t.txt == "j"