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

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

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

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

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

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

l.t = m
l.v = m
h.p = f
f.t = m
f.v = k
m.t = f
m.v = f
k.t = m
k.v = l
j.p = i
c.p = i
g.t = k
g.v = k
i.t = m
i.v = m
n.p = l
assert k.v.v.v.v.txt == "k"