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

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

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

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

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

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

d = A("d")
h = B("h")
l = C("l")
j = D("j")
a = E("a")
n = F("n")

d.t = l
d.w = n
h.z = n
l.x = j
l.q = h
j.s = h
j.o = h
j.w = l
a.s = j
a.z = l
n.t = d
n.y = d
n.o = d
n.p = h
n.u = h
assert n.u.z.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.w: F = None
        self.txt = txt

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

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

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

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

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

d = A("d")
h = B("h")
l = C("l")
j = D("j")
a = E("a")
n = F("n")

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