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

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.t: A = None
        self.p: B = None
        self.w: D = None
        self.x: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: E = None
        self.x: C = None
        self.o: D = None
        self.txt = txt

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

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

h.x = d
h.z = i
l.o = i
l.q = i
l.z = h
d.s = c
d.t = h
d.p = l
d.x = l
d.w = k
c.y = i
c.x = d
c.o = k
i.p = l
i.w = l
k.y = i
k.x = d
k.o = c
assert k.x.t.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.z: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.t: A = None
        self.p: B = None
        self.w: D = None
        self.x: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: E = None
        self.x: C = None
        self.o: D = None
        self.txt = txt

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

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

h.x = d
h.z = i
l.o = i
l.q = i
l.z = h
d.s = c
d.t = h
d.p = l
d.x = l
d.w = k
c.y = i
c.x = d
c.o = k
i.p = l
i.w = l
k.y = i
k.x = d
k.o = c
assert k.x.t.x.p.txt == "l"