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

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.o: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.v: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.o: D = None
        self.s: B = None
        self.p: A = None
        self.txt = txt

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

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

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.o: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.v: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.o: D = None
        self.s: B = None
        self.p: A = None
        self.txt = txt

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

d.y = l
d.x = l
d.p = l
d.q = i
d.w = i
d.s = k
j.q = d
j.o = d
i.x = l
i.y = k
i.q = j
i.w = j
i.z = h
k.u = d
k.v = h
h.x = i
l.o = k
l.s = j
l.p = d
assert h.x.z.x.txt == "i"