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

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

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

n = A("n")
k = B("k")
h = C("h")
i = A("i")
a = B("a")
b = C("b")
f = B("f")
m = C("m")
j = A("j")

n.r = m
k.z = f
h.t = n
i.r = m
a.z = k
b.t = n
f.z = k
m.t = i
j.r = b
assert b.t.r.t.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

n = A("n")
k = B("k")
h = C("h")
i = A("i")
a = B("a")
b = C("b")
f = B("f")
m = C("m")
j = A("j")

n.r = m
k.z = f
h.t = n
i.r = m
a.z = k
b.t = n
f.z = k
m.t = i
j.r = b
assert b.t.r.t.r.t.txt == "i"