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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.q: C = None
        self.t: B = None
        self.txt = txt

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

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

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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.q: C = None
        self.t: B = None
        self.txt = txt

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

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

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