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

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

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

i = A("i")
b = B("b")
k = C("k")
d = B("d")
m = B("m")

i.v = k
i.x = k
b.x = m
b.v = i
k.u = m
d.x = m
d.v = i
m.x = d
m.v = i
assert k.u.v.v.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.x: C = None
        self.txt = txt

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

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

i = A("i")
b = B("b")
k = C("k")
d = B("d")
m = B("m")

i.v = k
i.x = k
b.x = m
b.v = i
k.u = m
d.x = m
d.v = i
m.x = d
m.v = i
assert k.u.v.v.u.x.txt == "d"