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

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

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

k = A("k")
l = B("l")
n = C("n")
d = C("d")
e = A("e")

k.q = e
k.o = e
k.x = e
l.u = n
l.p = e
n.s = d
n.q = e
n.v = l
d.s = n
d.q = e
d.v = l
e.q = k
e.o = k
e.x = k
assert e.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.o: A = None
        self.x: A = None
        self.txt = txt

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

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

k = A("k")
l = B("l")
n = C("n")
d = C("d")
e = A("e")

k.q = e
k.o = e
k.x = e
l.u = n
l.p = e
n.s = d
n.q = e
n.v = l
d.s = n
d.q = e
d.v = l
e.q = k
e.o = k
e.x = k
assert e.q.q.q.txt == "k"