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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.v: B = None
        self.z: G = None
        self.t: E = None
        self.txt = txt

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

m = A("m")
a = B("a")
c = C("c")
k = D("k")
d = E("d")
h = F("h")
i = G("i")
f = C("f")
e = A("e")

m.v = i
m.t = d
m.r = f
m.p = a
a.p = e
a.w = c
c.q = m
k.s = a
k.v = h
d.s = h
d.z = a
h.v = a
h.z = i
h.t = d
i.x = h
i.q = k
i.t = a
f.q = e
e.v = i
e.t = d
e.r = f
e.p = a
assert d.z.p.r.q.v.x.v.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: G = None
        self.t: E = None
        self.r: C = None
        self.p: B = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.v: B = None
        self.z: G = None
        self.t: E = None
        self.txt = txt

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

m = A("m")
a = B("a")
c = C("c")
k = D("k")
d = E("d")
h = F("h")
i = G("i")
f = C("f")
e = A("e")

m.v = i
m.t = d
m.r = f
m.p = a
a.p = e
a.w = c
c.q = m
k.s = a
k.v = h
d.s = h
d.z = a
h.v = a
h.z = i
h.t = d
i.x = h
i.q = k
i.t = a
f.q = e
e.v = i
e.t = d
e.r = f
e.p = a
assert d.z.p.r.q.v.x.v.p.r.txt == "f"