class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.z: B = None
        self.s: B = None
        self.txt = txt

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

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

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

h = A("h")
i = B("i")
c = C("c")
a = D("a")
d = B("d")

h.x = a
h.z = d
h.s = i
i.y = d
c.z = a
c.u = a
c.y = h
c.v = d
a.z = c
d.y = i
assert i.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.z: B = None
        self.s: B = None
        self.txt = txt

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

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

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

h = A("h")
i = B("i")
c = C("c")
a = D("a")
d = B("d")

h.x = a
h.z = d
h.s = i
i.y = d
c.z = a
c.u = a
c.y = h
c.v = d
a.z = c
d.y = i
assert i.y.y.y.y.txt == "i"