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

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

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

j = A("j")
c = B("c")
m = C("m")
g = C("g")
e = C("e")
f = B("f")
h = B("h")
a = A("a")
k = C("k")

j.r = g
j.x = a
c.v = j
m.u = c
m.y = k
m.z = a
g.u = h
g.y = e
g.z = j
e.u = f
e.y = k
e.z = a
f.v = j
h.v = a
a.r = g
a.x = j
k.u = c
k.y = g
k.z = a
assert h.v.r.u.v.r.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.x: A = None
        self.txt = txt

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

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

j = A("j")
c = B("c")
m = C("m")
g = C("g")
e = C("e")
f = B("f")
h = B("h")
a = A("a")
k = C("k")

j.r = g
j.x = a
c.v = j
m.u = c
m.y = k
m.z = a
g.u = h
g.y = e
g.z = j
e.u = f
e.y = k
e.z = a
f.v = j
h.v = a
a.r = g
a.x = j
k.u = c
k.y = g
k.z = a
assert h.v.r.u.v.r.z.r.txt == "g"