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

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.x: D = None
        self.y: F = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.q: D = None
        self.x: A = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.q: E = None
        self.u: F = None
        self.s: E = None
        self.r: B = None
        self.w: F = None
        self.txt = txt

i = A("i")
a = B("a")
n = C("n")
f = D("f")
m = E("m")
k = F("k")
g = G("g")
e = H("e")

i.q = m
a.p = n
a.r = n
a.w = m
n.z = f
n.x = f
n.y = k
f.w = k
f.r = g
f.v = a
m.s = i
m.x = g
k.x = m
g.q = f
g.x = i
e.q = m
e.s = m
e.u = k
e.w = k
e.r = a
assert a.p.x.r.x.q.x.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.x: D = None
        self.y: F = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.q: D = None
        self.x: A = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.q: E = None
        self.u: F = None
        self.s: E = None
        self.r: B = None
        self.w: F = None
        self.txt = txt

i = A("i")
a = B("a")
n = C("n")
f = D("f")
m = E("m")
k = F("k")
g = G("g")
e = H("e")

i.q = m
a.p = n
a.r = n
a.w = m
n.z = f
n.x = f
n.y = k
f.w = k
f.r = g
f.v = a
m.s = i
m.x = g
k.x = m
g.q = f
g.x = i
e.q = m
e.s = m
e.u = k
e.w = k
e.r = a
assert a.p.x.r.x.q.x.x.q.txt == "m"