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

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

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

j = A("j")
e = B("e")
n = C("n")
f = C("f")
c = A("c")

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

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

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

j = A("j")
e = B("e")
n = C("n")
f = C("f")
c = A("c")

j.u = f
j.x = n
j.o = c
e.y = n
n.t = f
f.t = n
c.u = n
c.x = f
c.o = j
assert f.t.t.t.t.t.txt == "n"