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

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

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

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

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

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

f = A("f")
k = B("k")
g = C("g")
i = D("i")
e = E("e")
n = F("n")

f.s = n
f.o = i
k.s = g
k.o = g
k.t = e
k.x = f
g.x = k
g.s = n
g.q = i
g.o = f
i.x = k
i.r = k
i.y = g
e.u = i
e.y = g
n.u = k
n.q = e
assert g.x.x.s.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: F = None
        self.o: D = None
        self.txt = txt

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

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

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

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

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

f = A("f")
k = B("k")
g = C("g")
i = D("i")
e = E("e")
n = F("n")

f.s = n
f.o = i
k.s = g
k.o = g
k.t = e
k.x = f
g.x = k
g.s = n
g.q = i
g.o = f
i.x = k
i.r = k
i.y = g
e.u = i
e.y = g
n.u = k
n.q = e
assert g.x.x.s.q.u.txt == "i"