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

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

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

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

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

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

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

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

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

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

a.y = c
a.t = c
a.q = i
a.r = j
c.z = a
i.y = c
i.z = j
j.y = e
h.y = e
e.z = b
b.y = e
b.t = c
b.q = i
b.r = h
assert a.t.z.y.z.y.z.txt == "a"