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

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

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

class D:
    def __init__(self, txt: str):
        self.y: G = None
        self.z: A = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.x: A = None
        self.p: E = None
        self.u: G = None
        self.r: B = None
        self.txt = txt

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.y: G = None
        self.z: A = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.x: A = None
        self.p: E = None
        self.u: G = None
        self.r: B = None
        self.txt = txt

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

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

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