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

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

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

i = A("i")
j = B("j")
b = C("b")
e = B("e")

i.v = e
j.u = b
j.q = i
b.p = i
b.x = i
e.u = b
e.q = i
assert i.v.u.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

i = A("i")
j = B("j")
b = C("b")
e = B("e")

i.v = e
j.u = b
j.q = i
b.p = i
b.x = i
e.u = b
e.q = i
assert i.v.u.p.v.txt == "e"