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

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

m = A("m")
f = B("f")
j = B("j")
l = B("l")
e = B("e")
i = A("i")

m.t = i
f.p = j
f.v = i
j.p = l
j.v = i
l.p = f
l.v = i
e.p = l
e.v = m
i.t = m
assert i.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

m = A("m")
f = B("f")
j = B("j")
l = B("l")
e = B("e")
i = A("i")

m.t = i
f.p = j
f.v = i
j.p = l
j.v = i
l.p = f
l.v = i
e.p = l
e.v = m
i.t = m
assert i.t.t.t.t.txt == "i"