class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.r: B = None
        self.y: D = None
        self.z: B = None
        self.u: C = None
        self.v: B = None
        self.txt = txt

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

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

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

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

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

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

c = A("c")
g = B("g")
e = C("e")
d = D("d")
b = E("b")
f = F("f")
m = G("m")

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

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

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

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

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

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

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

c = A("c")
g = B("g")
e = C("e")
d = D("d")
b = E("b")
f = F("f")
m = G("m")

c.x = d
c.y = d
c.r = g
c.z = g
c.v = g
c.u = e
g.v = c
g.u = f
g.q = b
e.o = g
e.y = g
e.x = m
e.p = f
e.w = c
e.t = d
d.y = b
b.r = g
b.w = f
b.u = e
b.y = m
f.s = c
f.q = c
f.y = e
f.x = e
f.u = m
m.z = d
assert g.u.x.p.s.v.q.r.txt == "g"