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

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.u: D = None
        self.z: B = None
        self.w: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.s: B = None
        self.r: B = None
        self.w: C = None
        self.txt = txt

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

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

a.t = h
a.q = h
d.q = i
d.z = a
h.p = j
h.u = i
h.z = d
h.w = a
i.t = j
i.s = d
i.r = d
i.w = h
j.o = d
assert d.z.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.q: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.u: D = None
        self.z: B = None
        self.w: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.s: B = None
        self.r: B = None
        self.w: C = None
        self.txt = txt

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

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

a.t = h
a.q = h
d.q = i
d.z = a
h.p = j
h.u = i
h.z = d
h.w = a
i.t = j
i.s = d
i.r = d
i.w = h
j.o = d
assert d.z.q.z.txt == "d"