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

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: G = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.w: G = None
        self.s: D = None
        self.q: C = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.z: F = None
        self.w: E = None
        self.y: E = None
        self.t: E = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: G = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.w: G = None
        self.s: D = None
        self.q: C = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.z: F = None
        self.w: E = None
        self.y: E = None
        self.t: E = None
        self.x: D = None
        self.txt = txt

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

d.u = m
d.z = h
d.w = f
h.p = c
m.v = a
m.w = d
m.q = f
a.v = n
a.u = d
n.w = c
f.w = c
f.s = a
f.q = m
c.z = f
c.w = n
c.y = n
c.t = n
c.x = a
assert n.w.z.q.w.u.txt == "m"