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

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.y: E = None
        self.r: C = None
        self.z: E = None
        self.txt = txt

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

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

n = A("n")
c = B("c")
k = C("k")
m = D("m")
e = E("e")
h = F("h")
d = D("d")
f = C("f")

n.y = f
n.q = m
c.w = e
k.x = e
k.t = m
m.q = e
m.y = e
m.z = e
m.r = f
e.q = c
e.v = c
h.o = e
d.q = e
d.y = e
d.z = e
d.r = f
f.x = e
f.t = m
assert k.x.q.w.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.y: E = None
        self.r: C = None
        self.z: E = None
        self.txt = txt

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

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

n = A("n")
c = B("c")
k = C("k")
m = D("m")
e = E("e")
h = F("h")
d = D("d")
f = C("f")

n.y = f
n.q = m
c.w = e
k.x = e
k.t = m
m.q = e
m.y = e
m.z = e
m.r = f
e.q = c
e.v = c
h.o = e
d.q = e
d.y = e
d.z = e
d.r = f
f.x = e
f.t = m
assert k.x.q.w.v.w.txt == "e"