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

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

class C:
    def __init__(self, txt: str):
        self.y: G = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.t: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.w: H = None
        self.t: F = None
        self.z: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.r: G = None
        self.u: E = None
        self.x: E = None
        self.y: D = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: H = None
        self.q: B = None
        self.v: C = None
        self.x: B = None
        self.txt = txt

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.y: G = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.t: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.w: H = None
        self.t: F = None
        self.z: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.r: G = None
        self.u: E = None
        self.x: E = None
        self.y: D = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: H = None
        self.q: B = None
        self.v: C = None
        self.x: B = None
        self.txt = txt

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

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

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