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

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

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

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

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

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

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