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

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.u: F = None
        self.z: C = None
        self.t: F = None
        self.txt = txt

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

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

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

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

k = A("k")
f = B("f")
d = C("d")
e = D("e")
i = E("i")
c = F("c")

k.q = i
f.y = e
f.u = c
f.t = c
f.z = d
d.y = e
d.z = f
e.q = k
e.x = k
e.w = d
e.o = d
e.u = f
i.r = f
i.q = f
c.w = e
c.s = d
c.p = f
assert k.q.r.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.u: F = None
        self.z: C = None
        self.t: F = None
        self.txt = txt

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

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

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

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

k = A("k")
f = B("f")
d = C("d")
e = D("e")
i = E("i")
c = F("c")

k.q = i
f.y = e
f.u = c
f.t = c
f.z = d
d.y = e
d.z = f
e.q = k
e.x = k
e.w = d
e.o = d
e.u = f
i.r = f
i.q = f
c.w = e
c.s = d
c.p = f
assert k.q.r.z.y.txt == "e"