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

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

h = A("h")
c = B("c")
n = A("n")
l = B("l")
b = A("b")
k = B("k")
f = B("f")

h.x = b
h.v = l
c.q = b
c.t = f
n.x = h
n.v = l
l.q = b
l.t = k
b.x = h
b.v = f
k.q = h
k.t = l
f.q = b
f.t = l
assert b.v.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.v: B = None
        self.txt = txt

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

h = A("h")
c = B("c")
n = A("n")
l = B("l")
b = A("b")
k = B("k")
f = B("f")

h.x = b
h.v = l
c.q = b
c.t = f
n.x = h
n.v = l
l.q = b
l.t = k
b.x = h
b.v = f
k.q = h
k.t = l
f.q = b
f.t = l
assert b.v.q.x.txt == "h"