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

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

d = A("d")
i = B("i")
f = A("f")
c = A("c")
m = A("m")

d.p = c
i.v = f
f.p = m
c.p = m
m.p = c
assert f.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

d = A("d")
i = B("i")
f = A("f")
c = A("c")
m = A("m")

d.p = c
i.v = f
f.p = m
c.p = m
m.p = c
assert f.p.p.p.p.p.txt == "m"