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

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

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

j = A("j")
g = B("g")
k = C("k")

j.q = g
j.v = g
j.u = k
g.u = j
g.x = j
g.o = k
k.q = j
assert g.x.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: C = None
        self.v: B = None
        self.txt = txt

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

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

j = A("j")
g = B("g")
k = C("k")

j.q = g
j.v = g
j.u = k
g.u = j
g.x = j
g.o = k
k.q = j
assert g.x.v.u.txt == "j"