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

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.p: E = None
        self.t: F = None
        self.y: E = None
        self.r: D = None
        self.txt = txt

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

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

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

k = A("k")
d = B("d")
f = C("f")
m = D("m")
n = E("n")
c = F("c")

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

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.p: E = None
        self.t: F = None
        self.y: E = None
        self.r: D = None
        self.txt = txt

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

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

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

k = A("k")
d = B("d")
f = C("f")
m = D("m")
n = E("n")
c = F("c")

k.x = c
d.q = k
d.x = f
d.s = n
f.z = m
f.r = m
f.p = n
f.y = n
f.t = c
m.t = d
m.q = k
n.q = d
n.z = f
n.w = k
c.w = f
c.o = f
assert k.x.o.z.t.q.x.txt == "c"