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

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

f = A("f")
g = B("g")
j = B("j")
a = A("a")
l = A("l")
d = A("d")
b = A("b")
h = A("h")

f.v = b
f.p = j
g.y = b
j.y = f
a.v = h
a.p = j
l.v = d
l.p = j
d.v = a
d.p = j
b.v = f
b.p = g
h.v = l
h.p = j
assert f.v.p.y.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.p: B = None
        self.txt = txt

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

f = A("f")
g = B("g")
j = B("j")
a = A("a")
l = A("l")
d = A("d")
b = A("b")
h = A("h")

f.v = b
f.p = j
g.y = b
j.y = f
a.v = h
a.p = j
l.v = d
l.p = j
d.v = a
d.p = j
b.v = f
b.p = g
h.v = l
h.p = j
assert f.v.p.y.p.y.txt == "b"