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

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.w: C = None
        self.o: C = None
        self.q: E = None
        self.r: E = None
        self.txt = txt

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.w: C = None
        self.o: C = None
        self.q: E = None
        self.r: E = None
        self.txt = txt

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

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

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

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

i.y = l
i.r = l
i.z = j
i.p = j
i.q = j
j.y = i
j.w = l
j.o = l
j.q = d
j.r = d
l.r = i
l.p = i
h.p = j
h.z = j
h.r = i
h.y = l
h.q = d
d.p = j
d.t = l
assert h.p.r.p.txt == "j"