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

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

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

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

c.o = f
j.t = n
j.u = b
j.x = b
k.o = n
k.x = j
k.q = c
f.o = c
b.t = n
b.u = j
b.x = j
n.o = k
n.x = b
n.q = c
assert j.t.q.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

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

c.o = f
j.t = n
j.u = b
j.x = b
k.o = n
k.x = j
k.q = c
f.o = c
b.t = n
b.u = j
b.x = j
n.o = k
n.x = b
n.q = c
assert j.t.q.o.o.o.txt == "f"