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

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

h = A("h")
e = B("e")
i = B("i")
g = A("g")
c = A("c")
f = A("f")
m = B("m")
j = B("j")
k = A("k")

h.q = c
e.v = i
i.v = j
g.q = k
c.q = h
f.q = h
m.v = j
j.v = i
k.q = h
assert c.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

h = A("h")
e = B("e")
i = B("i")
g = A("g")
c = A("c")
f = A("f")
m = B("m")
j = B("j")
k = A("k")

h.q = c
e.v = i
i.v = j
g.q = k
c.q = h
f.q = h
m.v = j
j.v = i
k.q = h
assert c.q.q.q.txt == "h"