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

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.q: A = None
        self.x: 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.y: C = None
        self.r: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.t: B = None
        self.q: C = None
        self.p: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: E = None
        self.s: A = None
        self.r: B = None
        self.p: B = None
        self.q: C = None
        self.txt = txt

e = A("e")
i = B("i")
b = C("b")
c = D("c")
f = E("f")
a = F("a")

e.q = f
e.z = b
i.z = e
i.q = e
i.x = f
b.x = i
c.y = b
c.r = f
f.x = a
f.t = i
f.q = b
f.p = e
a.z = f
a.s = e
a.r = i
a.p = i
a.q = b
assert i.x.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.z: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.q: A = None
        self.x: 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.y: C = None
        self.r: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.t: B = None
        self.q: C = None
        self.p: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: E = None
        self.s: A = None
        self.r: B = None
        self.p: B = None
        self.q: C = None
        self.txt = txt

e = A("e")
i = B("i")
b = C("b")
c = D("c")
f = E("f")
a = F("a")

e.q = f
e.z = b
i.z = e
i.q = e
i.x = f
b.x = i
c.y = b
c.r = f
f.x = a
f.t = i
f.q = b
f.p = e
a.z = f
a.s = e
a.r = i
a.p = i
a.q = b
assert i.x.t.x.txt == "f"