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

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

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

c = A("c")
f = B("f")
l = C("l")
j = C("j")
k = A("k")
e = C("e")
n = A("n")
a = B("a")

c.t = a
c.p = k
f.v = c
f.r = k
l.r = c
j.r = k
k.t = f
k.p = c
e.r = k
n.t = a
n.p = k
a.v = n
a.r = c
assert c.t.r.t.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: A = None
        self.txt = txt

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

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

c = A("c")
f = B("f")
l = C("l")
j = C("j")
k = A("k")
e = C("e")
n = A("n")
a = B("a")

c.t = a
c.p = k
f.v = c
f.r = k
l.r = c
j.r = k
k.t = f
k.p = c
e.r = k
n.t = a
n.p = k
a.v = n
a.r = c
assert c.t.r.t.r.t.r.txt == "c"