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

class B:
    def __init__(self, txt: str):
        self.z: E = None
        self.t: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: F = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.t: E = None
        self.x: B = None
        self.txt = txt

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

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

g.w = n
n.z = b
n.t = c
m.o = c
d.s = g
d.z = n
d.x = n
d.u = n
d.w = n
d.r = m
b.o = a
c.t = b
c.x = n
a.s = d
assert m.o.t.o.s.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: E = None
        self.t: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: F = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.t: E = None
        self.x: B = None
        self.txt = txt

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

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

g.w = n
n.z = b
n.t = c
m.o = c
d.s = g
d.z = n
d.x = n
d.u = n
d.w = n
d.r = m
b.o = a
c.t = b
c.x = n
a.s = d
assert m.o.t.o.s.r.o.txt == "c"