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

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

a = A("a")
e = B("e")
j = B("j")
b = B("b")
l = B("l")
f = A("f")
c = A("c")
i = B("i")
g = B("g")

a.p = l
a.v = f
e.x = c
j.x = c
b.x = f
l.x = f
f.p = j
f.v = c
c.p = b
c.v = a
i.x = c
g.x = a
assert c.p.x.p.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: A = None
        self.txt = txt

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

a = A("a")
e = B("e")
j = B("j")
b = B("b")
l = B("l")
f = A("f")
c = A("c")
i = B("i")
g = B("g")

a.p = l
a.v = f
e.x = c
j.x = c
b.x = f
l.x = f
f.p = j
f.v = c
c.p = b
c.v = a
i.x = c
g.x = a
assert c.p.x.p.x.v.txt == "a"