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

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

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

f = A("f")
j = B("j")
g = C("g")
k = A("k")
c = C("c")
i = B("i")
b = B("b")
a = A("a")

f.r = k
j.x = b
j.t = f
j.v = c
g.t = c
g.z = a
k.r = a
c.t = g
c.z = f
i.x = j
i.t = f
i.v = c
b.x = i
b.t = f
b.v = c
a.r = f
assert c.t.t.t.t.t.z.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.x: B = None
        self.t: A = None
        self.v: C = None
        self.txt = txt

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

f = A("f")
j = B("j")
g = C("g")
k = A("k")
c = C("c")
i = B("i")
b = B("b")
a = A("a")

f.r = k
j.x = b
j.t = f
j.v = c
g.t = c
g.z = a
k.r = a
c.t = g
c.z = f
i.x = j
i.t = f
i.v = c
b.x = i
b.t = f
b.v = c
a.r = f
assert c.t.t.t.t.t.z.r.r.txt == "k"