class A:
    def __init__(self, txt: str):
        self.x: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.p: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.o: B = None
        self.t: E = None
        self.z: C = None
        self.s: B = None
        self.txt = txt

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

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

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

h = A("h")
m = B("m")
n = C("n")
g = D("g")
e = E("e")
d = F("d")
c = G("c")
k = F("k")

h.x = d
m.r = e
m.p = g
n.o = c
n.w = d
n.x = g
g.r = h
g.o = m
g.s = m
g.t = e
g.z = n
e.z = h
e.v = g
e.q = k
d.w = k
c.z = g
k.w = d
assert n.o.z.r.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.p: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.o: B = None
        self.t: E = None
        self.z: C = None
        self.s: B = None
        self.txt = txt

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

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

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

h = A("h")
m = B("m")
n = C("n")
g = D("g")
e = E("e")
d = F("d")
c = G("c")
k = F("k")

h.x = d
m.r = e
m.p = g
n.o = c
n.w = d
n.x = g
g.r = h
g.o = m
g.s = m
g.t = e
g.z = n
e.z = h
e.v = g
e.q = k
d.w = k
c.z = g
k.w = d
assert n.o.z.r.x.w.txt == "k"