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

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

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

k = A("k")
c = B("c")
b = C("b")
m = A("m")
a = B("a")
h = C("h")
g = C("g")

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

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

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

k = A("k")
c = B("c")
b = C("b")
m = A("m")
a = B("a")
h = C("h")
g = C("g")

k.r = m
k.x = m
k.v = m
c.w = g
b.o = k
m.r = k
m.x = k
m.v = k
a.w = h
h.o = m
g.o = m
assert b.o.x.v.v.txt == "m"