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

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

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

f = A("f")
j = B("j")
m = C("m")
k = B("k")
g = B("g")
l = A("l")
a = C("a")

f.x = l
j.x = g
m.v = f
m.w = l
k.x = j
g.x = k
l.x = f
a.v = l
a.w = f
assert f.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

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

f = A("f")
j = B("j")
m = C("m")
k = B("k")
g = B("g")
l = A("l")
a = C("a")

f.x = l
j.x = g
m.v = f
m.w = l
k.x = j
g.x = k
l.x = f
a.v = l
a.w = f
assert f.x.x.x.x.x.txt == "l"