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

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

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

d = A("d")
a = B("a")
g = C("g")
m = B("m")
h = C("h")
b = C("b")
e = B("e")
j = A("j")
n = B("n")

d.r = j
a.z = b
a.v = m
g.x = j
g.v = n
g.w = n
m.z = g
m.v = n
h.x = d
h.v = a
h.w = m
b.x = j
b.v = m
b.w = a
e.z = g
e.v = n
j.r = d
n.z = h
n.v = m
assert h.x.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

d = A("d")
a = B("a")
g = C("g")
m = B("m")
h = C("h")
b = C("b")
e = B("e")
j = A("j")
n = B("n")

d.r = j
a.z = b
a.v = m
g.x = j
g.v = n
g.w = n
m.z = g
m.v = n
h.x = d
h.v = a
h.w = m
b.x = j
b.v = m
b.w = a
e.z = g
e.v = n
j.r = d
n.z = h
n.v = m
assert h.x.r.r.r.r.r.r.r.txt == "j"