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

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

i = A("i")
d = B("d")
a = B("a")
e = A("e")
c = B("c")
k = B("k")
b = B("b")
f = A("f")
n = B("n")

i.x = e
d.p = e
a.p = i
e.x = f
c.p = f
k.p = e
b.p = f
f.x = i
n.p = f
assert c.p.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

i = A("i")
d = B("d")
a = B("a")
e = A("e")
c = B("c")
k = B("k")
b = B("b")
f = A("f")
n = B("n")

i.x = e
d.p = e
a.p = i
e.x = f
c.p = f
k.p = e
b.p = f
f.x = i
n.p = f
assert c.p.x.x.txt == "e"