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

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

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

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

i.v = j
j.v = m
j.u = i
f.v = i
m.v = j
m.u = i
assert m.v.v.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

i.v = j
j.v = m
j.u = i
f.v = i
m.v = j
m.u = i
assert m.v.v.v.u.txt == "i"