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

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.v: B = None
        self.r: D = None
        self.t: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.p: A = None
        self.z: F = None
        self.w: F = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.p: D = None
        self.z: F = None
        self.t: G = None
        self.o: A = None
        self.w: G = None
        self.txt = txt

b = A("b")
j = B("j")
h = C("h")
m = D("m")
g = E("g")
f = F("f")
c = G("c")
e = H("e")
a = A("a")
n = F("n")

b.p = a
b.r = h
b.x = h
b.s = g
j.w = m
h.u = m
m.t = g
m.s = a
g.w = h
g.v = j
g.r = m
g.t = n
f.o = h
c.p = a
c.z = f
c.w = n
e.p = m
e.z = f
e.t = c
e.w = c
e.o = a
a.p = b
a.r = h
a.x = h
a.s = g
n.o = h
assert m.t.r.s.p.s.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.r: C = None
        self.x: C = None
        self.s: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.v: B = None
        self.r: D = None
        self.t: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.p: A = None
        self.z: F = None
        self.w: F = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.p: D = None
        self.z: F = None
        self.t: G = None
        self.o: A = None
        self.w: G = None
        self.txt = txt

b = A("b")
j = B("j")
h = C("h")
m = D("m")
g = E("g")
f = F("f")
c = G("c")
e = H("e")
a = A("a")
n = F("n")

b.p = a
b.r = h
b.x = h
b.s = g
j.w = m
h.u = m
m.t = g
m.s = a
g.w = h
g.v = j
g.r = m
g.t = n
f.o = h
c.p = a
c.z = f
c.w = n
e.p = m
e.z = f
e.t = c
e.w = c
e.o = a
a.p = b
a.r = h
a.x = h
a.s = g
n.o = h
assert m.t.r.s.p.s.r.s.txt == "a"