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

class B:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: C = None
        self.u: C = None
        self.v: E = None
        self.w: B = None
        self.q: A = None
        self.y: E = None
        self.txt = txt

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: C = None
        self.u: C = None
        self.v: E = None
        self.w: B = None
        self.q: A = None
        self.y: E = None
        self.txt = txt

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

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

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

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

m.u = f
m.p = n
b.r = f
f.x = a
f.o = n
f.w = n
f.s = n
f.p = b
f.q = m
f.z = d
d.r = f
d.o = f
d.u = f
d.v = k
d.y = k
d.w = b
d.q = m
k.q = b
k.s = f
k.u = n
k.p = m
a.q = d
n.z = m
assert n.z.u.w.z.u.txt == "f"