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

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

d = A("d")
k = B("k")
f = B("f")
h = A("h")
j = B("j")
i = B("i")
n = B("n")

d.v = h
d.t = n
k.r = n
k.p = i
f.r = k
f.p = k
h.v = d
h.t = k
j.r = n
j.p = f
i.r = k
i.p = f
n.r = j
n.p = i
assert n.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.t: B = None
        self.txt = txt

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

d = A("d")
k = B("k")
f = B("f")
h = A("h")
j = B("j")
i = B("i")
n = B("n")

d.v = h
d.t = n
k.r = n
k.p = i
f.r = k
f.p = k
h.v = d
h.t = k
j.r = n
j.p = f
i.r = k
i.p = f
n.r = j
n.p = i
assert n.r.r.r.r.r.r.r.txt == "j"