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

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

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

class D:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: B = None
        self.z: G = None
        self.t: B = None
        self.q: F = None
        self.r: F = None
        self.p: D = None
        self.v: A = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.x: C = None
        self.t: D = None
        self.y: F = None
        self.u: A = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: B = None
        self.z: G = None
        self.t: B = None
        self.q: F = None
        self.r: F = None
        self.p: D = None
        self.v: A = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.x: C = None
        self.t: D = None
        self.y: F = None
        self.u: A = None
        self.txt = txt

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

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