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

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

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

k = A("k")
j = B("j")
f = C("f")
n = A("n")

k.o = j
k.p = j
k.q = n
j.o = f
f.u = n
n.o = j
n.p = j
n.q = k
assert n.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: A = None
        self.p: B = None
        self.txt = txt

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

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

k = A("k")
j = B("j")
f = C("f")
n = A("n")

k.o = j
k.p = j
k.q = n
j.o = f
f.u = n
n.o = j
n.p = j
n.q = k
assert n.q.q.q.txt == "k"