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

class B:
    def __init__(self, txt: str):
        self.y: B = None
        self.z: A = None
        self.t: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: C = None
        self.p: C = None
        self.t: B = None
        self.v: A = None
        self.s: G = None
        self.z: A = None
        self.txt = txt

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.y: B = None
        self.z: A = None
        self.t: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: C = None
        self.p: C = None
        self.t: B = None
        self.v: A = None
        self.s: G = None
        self.z: A = None
        self.txt = txt

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

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

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

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

c.p = d
m.y = a
m.z = c
m.t = k
g.u = n
g.r = m
g.y = i
i.q = c
i.v = c
i.z = c
i.x = g
i.p = g
i.t = m
i.s = d
k.t = n
k.u = n
k.x = i
k.s = i
k.r = d
k.q = g
k.v = g
n.p = g
n.x = i
d.r = c
a.y = m
a.z = c
a.t = k
assert k.s.s.r.p.r.p.r.p.txt == "d"