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

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.u: A = None
        self.r: B = None
        self.txt = txt

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

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

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

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.u: A = None
        self.r: B = None
        self.txt = txt

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

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

g.v = b
a.s = l
a.r = l
a.u = j
b.u = g
b.s = a
f.v = b
h.u = j
h.s = a
j.v = b
m.u = c
m.s = a
l.s = a
l.r = a
l.u = f
c.v = b
assert h.u.v.u.v.s.txt == "a"