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

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

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

m = A("m")
l = B("l")
n = C("n")
j = A("j")
a = A("a")
f = C("f")
h = B("h")

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

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

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

m = A("m")
l = B("l")
n = C("n")
j = A("j")
a = A("a")
f = C("f")
h = B("h")

m.v = h
l.y = m
l.r = h
n.p = f
n.t = h
j.v = h
a.v = h
f.p = n
f.t = l
h.y = a
h.r = l
assert j.v.r.y.v.r.r.y.txt == "a"