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

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

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

a = A("a")
k = B("k")
e = C("e")
n = A("n")
g = A("g")
f = A("f")

a.q = k
k.o = e
k.v = n
e.s = a
e.x = k
n.q = k
g.q = k
f.q = k
assert e.x.o.x.v.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

a = A("a")
k = B("k")
e = C("e")
n = A("n")
g = A("g")
f = A("f")

a.q = k
k.o = e
k.v = n
e.s = a
e.x = k
n.q = k
g.q = k
f.q = k
assert e.x.o.x.v.q.v.txt == "n"