class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.s: E = None
        self.o: B = None
        self.w: C = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.w: D = None
        self.p: C = None
        self.u: B = None
        self.q: B = None
        self.txt = txt

h = A("h")
f = B("f")
g = C("g")
b = D("b")
d = E("d")
e = F("e")
n = C("n")

h.q = b
h.s = d
h.o = f
h.w = g
f.u = d
f.y = d
f.r = d
f.z = n
g.w = e
b.o = d
d.u = e
e.w = b
e.p = n
e.u = f
e.q = f
n.w = e
assert n.w.p.w.p.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.s: E = None
        self.o: B = None
        self.w: C = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.w: D = None
        self.p: C = None
        self.u: B = None
        self.q: B = None
        self.txt = txt

h = A("h")
f = B("f")
g = C("g")
b = D("b")
d = E("d")
e = F("e")
n = C("n")

h.q = b
h.s = d
h.o = f
h.w = g
f.u = d
f.y = d
f.r = d
f.z = n
g.w = e
b.o = d
d.u = e
e.w = b
e.p = n
e.u = f
e.q = f
n.w = e
assert n.w.p.w.p.w.p.txt == "n"