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

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

class C:
    def __init__(self, txt: str):
        self.y: G = None
        self.z: D = None
        self.o: A = None
        self.u: A = None
        self.txt = txt

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

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

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.y: G = None
        self.z: D = None
        self.o: A = None
        self.u: A = None
        self.txt = txt

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

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

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

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

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

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