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

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

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.w: C = None
        self.u: A = None
        self.o: F = None
        self.t: C = None
        self.r: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

j = A("j")
f = B("f")
d = C("d")
i = D("i")
m = E("m")
n = F("n")

j.t = n
f.t = m
d.x = f
i.z = d
i.w = d
i.t = d
i.u = j
i.r = j
i.o = n
m.x = j
n.r = m
n.t = m
n.x = m
n.q = i
assert m.x.t.t.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: F = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.w: C = None
        self.u: A = None
        self.o: F = None
        self.t: C = None
        self.r: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

j = A("j")
f = B("f")
d = C("d")
i = D("i")
m = E("m")
n = F("n")

j.t = n
f.t = m
d.x = f
i.z = d
i.w = d
i.t = d
i.u = j
i.r = j
i.o = n
m.x = j
n.r = m
n.t = m
n.x = m
n.q = i
assert m.x.t.t.x.t.txt == "n"