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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: F = None
        self.txt = txt

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

d.v = k
d.o = n
m.v = a
m.q = a
a.x = n
a.z = m
a.q = c
k.u = c
k.s = n
n.x = a
c.w = n
j.z = a
j.q = c
assert k.u.w.x.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.o: E = None
        self.txt = txt

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: F = None
        self.txt = txt

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

d.v = k
d.o = n
m.v = a
m.q = a
a.x = n
a.z = m
a.q = c
k.u = c
k.s = n
n.x = a
c.w = n
j.z = a
j.q = c
assert k.u.w.x.q.w.txt == "n"