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

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: B = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.u: A = None
        self.p: C = None
        self.x: D = None
        self.t: A = None
        self.txt = txt

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: B = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.u: A = None
        self.p: C = None
        self.x: D = None
        self.t: A = None
        self.txt = txt

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

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

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