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

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

d = A("d")
l = B("l")
i = A("i")
k = B("k")
c = A("c")
j = A("j")
f = B("f")

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

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

d = A("d")
l = B("l")
i = A("i")
k = B("k")
c = A("c")
j = A("j")
f = B("f")

d.p = l
d.o = i
l.v = d
i.p = k
i.o = d
k.v = d
c.p = k
c.o = i
j.p = k
j.o = i
f.v = c
assert f.v.o.o.p.v.p.v.txt == "d"