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

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.r: A = None
        self.t: A = None
        self.txt = txt

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

g.v = f
a.u = f
h.y = b
h.r = b
h.t = b
m.v = f
f.y = m
f.r = g
f.t = g
b.v = f
assert h.r.v.y.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.r: A = None
        self.t: A = None
        self.txt = txt

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

g.v = f
a.u = f
h.y = b
h.r = b
h.t = b
m.v = f
f.y = m
f.r = g
f.t = g
b.v = f
assert h.r.v.y.v.t.txt == "g"