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

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

f = A("f")
h = B("h")
l = A("l")
m = A("m")
d = B("d")
i = A("i")
b = A("b")
j = B("j")
c = B("c")
n = B("n")

f.v = j
h.p = b
h.u = j
l.v = h
m.v = n
d.p = f
d.u = j
i.v = c
b.v = h
j.p = m
j.u = h
c.p = l
c.u = n
n.p = b
n.u = c
assert c.p.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

f = A("f")
h = B("h")
l = A("l")
m = A("m")
d = B("d")
i = A("i")
b = A("b")
j = B("j")
c = B("c")
n = B("n")

f.v = j
h.p = b
h.u = j
l.v = h
m.v = n
d.p = f
d.u = j
i.v = c
b.v = h
j.p = m
j.u = h
c.p = l
c.u = n
n.p = b
n.u = c
assert c.p.v.p.txt == "b"