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

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

a = A("a")
m = B("m")
g = C("g")
i = D("i")
c = E("c")
j = E("j")
h = D("h")

a.p = m
m.t = g
m.z = g
m.x = i
m.w = a
m.o = a
g.u = m
g.v = m
g.y = a
g.o = c
i.q = c
c.w = m
c.p = a
c.u = a
j.w = m
j.p = a
j.u = a
h.q = c
assert c.p.p.x.q.w.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

a = A("a")
m = B("m")
g = C("g")
i = D("i")
c = E("c")
j = E("j")
h = D("h")

a.p = m
m.t = g
m.z = g
m.x = i
m.w = a
m.o = a
g.u = m
g.v = m
g.y = a
g.o = c
i.q = c
c.w = m
c.p = a
c.u = a
j.w = m
j.p = a
j.u = a
h.q = c
assert c.p.p.x.q.w.t.o.txt == "c"