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

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

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

k = A("k")
f = B("f")
m = C("m")
g = C("g")
b = A("b")
i = B("i")
l = A("l")
c = A("c")

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

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

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

k = A("k")
f = B("f")
m = C("m")
g = C("g")
b = A("b")
i = B("i")
l = A("l")
c = A("c")

k.v = b
k.x = b
f.w = i
m.o = b
g.o = l
b.v = k
b.x = l
i.w = f
l.v = c
l.x = k
c.v = l
c.x = b
assert b.x.v.v.txt == "l"