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

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

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

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

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

a = A("a")
g = B("g")
c = C("c")
f = D("f")
n = E("n")
m = B("m")
l = D("l")

a.x = m
g.t = m
g.p = m
g.q = f
g.u = c
c.o = g
c.x = n
c.y = a
f.y = n
f.t = n
f.q = m
f.r = a
f.w = a
n.w = m
n.r = a
n.p = c
m.t = g
m.p = g
m.q = l
m.u = c
l.y = n
l.t = n
l.q = m
l.r = a
l.w = a
assert g.p.q.r.x.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

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

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

a = A("a")
g = B("g")
c = C("c")
f = D("f")
n = E("n")
m = B("m")
l = D("l")

a.x = m
g.t = m
g.p = m
g.q = f
g.u = c
c.o = g
c.x = n
c.y = a
f.y = n
f.t = n
f.q = m
f.r = a
f.w = a
n.w = m
n.r = a
n.p = c
m.t = g
m.p = g
m.q = l
m.u = c
l.y = n
l.t = n
l.q = m
l.r = a
l.w = a
assert g.p.q.r.x.p.t.txt == "m"