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

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

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

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

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

h.u = i
h.y = i
c.p = i
j.v = i
j.t = h
i.o = j
i.t = j
i.z = j
i.r = c
assert i.z.v.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.y: D = None
        self.txt = txt

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

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

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

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

h.u = i
h.y = i
c.p = i
j.v = i
j.t = h
i.o = j
i.t = j
i.z = j
i.r = c
assert i.z.v.r.p.txt == "i"