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

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

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

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

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

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

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