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

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

d = A("d")
i = B("i")
k = C("k")
h = D("h")
n = E("n")
l = F("l")

d.y = n
d.w = i
i.y = l
i.p = l
i.t = k
i.q = k
i.o = d
i.w = h
k.u = h
h.r = i
h.x = d
h.w = n
h.q = k
n.z = h
l.w = k
assert k.u.w.z.q.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.w: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

d = A("d")
i = B("i")
k = C("k")
h = D("h")
n = E("n")
l = F("l")

d.y = n
d.w = i
i.y = l
i.p = l
i.t = k
i.q = k
i.o = d
i.w = h
k.u = h
h.r = i
h.x = d
h.w = n
h.q = k
n.z = h
l.w = k
assert k.u.w.z.q.u.w.txt == "n"