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

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

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

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

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

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

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