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

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

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

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

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

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

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

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

c.r = h
c.v = e
c.w = j
g.s = c
g.x = c
e.r = h
b.r = c
a.r = h
a.v = b
a.w = g
h.r = c
h.v = b
h.w = j
m.s = h
m.x = a
j.s = h
j.x = h
l.s = h
l.x = a
assert a.v.r.v.r.w.s.r.r.w.txt == "j"