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

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

h = A("h")
l = B("l")
g = A("g")
e = A("e")
c = A("c")

h.v = l
l.q = c
g.v = l
e.v = l
c.v = l
assert l.q.v.q.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

h = A("h")
l = B("l")
g = A("g")
e = A("e")
c = A("c")

h.v = l
l.q = c
g.v = l
e.v = l
c.v = l
assert l.q.v.q.v.q.txt == "c"