class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.t: G = None
        self.r: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: F = None
        self.q: G = None
        self.u: G = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

a.p = k
a.t = m
a.r = d
g.u = m
g.r = k
k.s = n
k.v = d
d.z = n
d.q = m
d.u = m
b.s = d
b.w = n
n.y = a
m.s = g
m.z = n
m.u = a
f.s = d
f.w = n
assert m.z.y.p.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.t: G = None
        self.r: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: F = None
        self.q: G = None
        self.u: G = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

a.p = k
a.t = m
a.r = d
g.u = m
g.r = k
k.s = n
k.v = d
d.z = n
d.q = m
d.u = m
b.s = d
b.w = n
n.y = a
m.s = g
m.z = n
m.u = a
f.s = d
f.w = n
assert m.z.y.p.v.q.txt == "m"