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

class B:
    def __init__(self, txt: str):
        self.z: G = None
        self.u: G = None
        self.y: E = None
        self.r: G = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: F = None
        self.v: E = None
        self.s: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.v: E = None
        self.t: E = None
        self.u: E = None
        self.o: A = None
        self.s: C = None
        self.q: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.q: A = None
        self.p: G = None
        self.o: A = None
        self.u: A = None
        self.txt = txt

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

k = A("k")
g = B("g")
h = C("h")
j = D("j")
n = E("n")
m = F("m")
d = G("d")

k.p = m
k.z = h
g.z = d
g.u = d
g.r = d
g.y = n
h.q = m
h.v = n
h.s = j
j.y = k
j.o = k
j.v = n
j.t = n
j.u = n
j.q = n
j.s = h
n.y = k
n.v = k
n.u = j
n.r = j
n.p = d
m.q = k
m.o = k
m.u = k
m.p = d
d.z = g
d.w = k
assert g.y.r.o.p.q.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.z: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: G = None
        self.u: G = None
        self.y: E = None
        self.r: G = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: F = None
        self.v: E = None
        self.s: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.v: E = None
        self.t: E = None
        self.u: E = None
        self.o: A = None
        self.s: C = None
        self.q: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.q: A = None
        self.p: G = None
        self.o: A = None
        self.u: A = None
        self.txt = txt

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

k = A("k")
g = B("g")
h = C("h")
j = D("j")
n = E("n")
m = F("m")
d = G("d")

k.p = m
k.z = h
g.z = d
g.u = d
g.r = d
g.y = n
h.q = m
h.v = n
h.s = j
j.y = k
j.o = k
j.v = n
j.t = n
j.u = n
j.q = n
j.s = h
n.y = k
n.v = k
n.u = j
n.r = j
n.p = d
m.q = k
m.o = k
m.u = k
m.p = d
d.z = g
d.w = k
assert g.y.r.o.p.q.z.q.txt == "m"