class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.t: C = None
        self.q: B = None
        self.s: B = None
        self.txt = txt

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

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

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

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

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

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

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

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

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

b.y = a
b.t = d
b.q = c
b.s = c
c.s = b
d.z = b
a.q = b
a.u = d
a.p = i
h.s = b
i.q = b
i.u = d
i.p = a
assert h.s.s.s.q.s.y.txt == "a"