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

class B:
    def __init__(self, txt: str):
        self.p: E = None
        self.v: C = None
        self.o: C = None
        self.q: G = None
        self.z: G = None
        self.r: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.q: D = None
        self.z: A = None
        self.v: A = None
        self.p: C = None
        self.x: C = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.p: C = None
        self.q: F = None
        self.s: E = None
        self.r: A = None
        self.txt = txt

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

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

class B:
    def __init__(self, txt: str):
        self.p: E = None
        self.v: C = None
        self.o: C = None
        self.q: G = None
        self.z: G = None
        self.r: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.q: D = None
        self.z: A = None
        self.v: A = None
        self.p: C = None
        self.x: C = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.p: C = None
        self.q: F = None
        self.s: E = None
        self.r: A = None
        self.txt = txt

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

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