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

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

k = A("k")
f = B("f")
b = A("b")
j = A("j")
c = B("c")
n = B("n")
a = A("a")
i = B("i")
e = A("e")
d = B("d")

k.q = a
k.t = b
f.v = j
f.r = n
b.q = j
b.t = e
j.q = a
j.t = e
c.v = a
c.r = f
n.v = b
n.r = f
a.q = b
a.t = b
i.v = a
i.r = n
e.q = k
e.t = a
d.v = k
d.r = c
assert d.v.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: A = None
        self.txt = txt

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

k = A("k")
f = B("f")
b = A("b")
j = A("j")
c = B("c")
n = B("n")
a = A("a")
i = B("i")
e = A("e")
d = B("d")

k.q = a
k.t = b
f.v = j
f.r = n
b.q = j
b.t = e
j.q = a
j.t = e
c.v = a
c.r = f
n.v = b
n.r = f
a.q = b
a.t = b
i.v = a
i.r = n
e.q = k
e.t = a
d.v = k
d.r = c
assert d.v.q.t.txt == "b"