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

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

d = A("d")
f = B("f")
i = A("i")
b = A("b")
j = B("j")

d.p = j
f.o = b
f.p = j
i.p = f
b.p = f
j.o = d
j.p = f
assert f.o.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

d = A("d")
f = B("f")
i = A("i")
b = A("b")
j = B("j")

d.p = j
f.o = b
f.p = j
i.p = f
b.p = f
j.o = d
j.p = f
assert f.o.p.p.txt == "j"