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.w: A = None
        self.q: B = None
        self.txt = txt

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

l.v = c
l.p = b
f.w = l
f.q = h
c.v = l
c.p = f
a.w = c
a.q = e
e.w = l
e.q = i
h.w = c
h.q = a
d.w = l
d.q = i
b.w = l
b.q = i
i.w = l
i.q = f
j.w = c
j.q = b
assert j.w.p.q.q.w.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.w: A = None
        self.q: B = None
        self.txt = txt

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

l.v = c
l.p = b
f.w = l
f.q = h
c.v = l
c.p = f
a.w = c
a.q = e
e.w = l
e.q = i
h.w = c
h.q = a
d.w = l
d.q = i
b.w = l
b.q = i
i.w = l
i.q = f
j.w = c
j.q = b
assert j.w.p.q.q.w.txt == "c"