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

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

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

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

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

g = A("g")
h = B("h")
d = C("d")
a = D("a")
m = E("m")
e = C("e")
f = D("f")

g.p = h
g.x = d
h.p = g
h.z = g
h.r = f
h.o = a
d.u = e
d.p = h
d.r = g
d.t = g
d.y = a
a.z = h
a.q = g
a.o = g
a.s = d
a.p = f
m.r = g
m.o = g
e.u = d
e.p = h
e.r = g
e.t = g
e.y = a
f.z = h
f.q = g
f.o = g
f.s = d
f.p = a
assert g.x.t.x.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.x: C = None
        self.txt = txt

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

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

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

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

g = A("g")
h = B("h")
d = C("d")
a = D("a")
m = E("m")
e = C("e")
f = D("f")

g.p = h
g.x = d
h.p = g
h.z = g
h.r = f
h.o = a
d.u = e
d.p = h
d.r = g
d.t = g
d.y = a
a.z = h
a.q = g
a.o = g
a.s = d
a.p = f
m.r = g
m.o = g
e.u = d
e.p = h
e.r = g
e.t = g
e.y = a
f.z = h
f.q = g
f.o = g
f.s = d
f.p = a
assert g.x.t.x.p.p.txt == "g"