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

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

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

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

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

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

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

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

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

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

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

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

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