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

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

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

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

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

d = A("d")
l = B("l")
c = C("c")
i = D("i")
g = E("g")
j = E("j")
h = D("h")
e = B("e")
a = A("a")

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

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

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

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

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

d = A("d")
l = B("l")
c = C("c")
i = D("i")
g = E("g")
j = E("j")
h = D("h")
e = B("e")
a = A("a")

d.t = c
d.q = g
l.t = a
c.p = l
c.z = l
i.z = c
i.x = c
i.q = c
i.p = a
g.x = a
g.s = i
g.o = l
j.x = a
j.s = h
j.o = e
h.z = c
h.x = c
h.q = c
h.p = a
e.t = a
a.t = c
a.q = j
assert g.x.t.p.txt == "l"