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

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

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

j = A("j")
n = B("n")
g = C("g")
b = B("b")
h = C("h")
d = A("d")
c = A("c")
i = A("i")
f = A("f")

j.r = g
j.v = c
j.t = b
n.y = g
n.s = j
g.q = h
b.y = h
b.s = i
h.q = g
d.r = g
d.v = f
d.t = n
c.r = g
c.v = f
c.t = b
i.r = h
i.v = c
i.t = n
f.r = g
f.v = j
f.t = n
assert h.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.v: A = None
        self.t: B = None
        self.txt = txt

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

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

j = A("j")
n = B("n")
g = C("g")
b = B("b")
h = C("h")
d = A("d")
c = A("c")
i = A("i")
f = A("f")

j.r = g
j.v = c
j.t = b
n.y = g
n.s = j
g.q = h
b.y = h
b.s = i
h.q = g
d.r = g
d.v = f
d.t = n
c.r = g
c.v = f
c.t = b
i.r = h
i.v = c
i.t = n
f.r = g
f.v = j
f.t = n
assert h.q.q.q.q.q.q.txt == "h"