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

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

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

e = A("e")
f = B("f")
m = C("m")
j = A("j")

e.x = j
e.o = j
f.r = j
f.v = m
m.x = f
m.v = e
j.x = e
j.o = e
assert f.v.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.o: A = None
        self.txt = txt

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

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

e = A("e")
f = B("f")
m = C("m")
j = A("j")

e.x = j
e.o = j
f.r = j
f.v = m
m.x = f
m.v = e
j.x = e
j.o = e
assert f.v.v.o.txt == "j"