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

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

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

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

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

i.z = h
i.t = c
i.p = c
a.p = c
c.q = i
c.p = h
h.y = i
assert a.p.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.t: C = None
        self.p: C = None
        self.txt = txt

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

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

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

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

i.z = h
i.t = c
i.p = c
a.p = c
c.q = i
c.p = h
h.y = i
assert a.p.q.p.txt == "c"