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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.u: A = None
        self.v: B = None
        self.x: D = None
        self.s: D = None
        self.y: F = None
        self.txt = txt

a = A("a")
h = B("h")
b = C("b")
f = D("f")
n = E("n")
k = F("k")
d = G("d")
i = D("i")
m = B("m")
g = B("g")

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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.u: A = None
        self.v: B = None
        self.x: D = None
        self.s: D = None
        self.y: F = None
        self.txt = txt

a = A("a")
h = B("h")
b = C("b")
f = D("f")
n = E("n")
k = F("k")
d = G("d")
i = D("i")
m = B("m")
g = B("g")

a.p = n
h.p = n
b.o = k
f.p = i
f.x = i
f.s = n
f.r = a
f.w = b
n.p = i
n.w = i
n.r = m
n.z = d
n.u = a
k.u = b
k.z = g
k.y = a
k.r = a
k.p = f
d.u = a
d.v = m
d.x = f
d.s = f
d.y = k
i.p = f
i.x = f
i.s = n
i.r = a
i.w = b
m.p = n
g.p = n
assert k.z.p.z.s.w.o.r.p.txt == "n"