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

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

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

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

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

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

n = A("n")
m = B("m")
j = C("j")
h = D("h")
d = E("d")
b = F("b")
g = E("g")

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

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

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

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

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

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

n = A("n")
m = B("m")
j = C("j")
h = D("h")
d = E("d")
b = F("b")
g = E("g")

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