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

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

c = A("c")
a = B("a")
h = A("h")
k = A("k")
n = B("n")
i = A("i")
f = B("f")
e = B("e")

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

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

c = A("c")
a = B("a")
h = A("h")
k = A("k")
n = B("n")
i = A("i")
f = B("f")
e = B("e")

c.x = n
c.q = h
a.t = c
a.v = f
h.x = a
h.q = c
k.x = a
k.q = i
n.t = h
n.v = a
i.x = n
i.q = c
f.t = k
f.v = n
e.t = i
e.v = f
assert c.x.v.t.q.q.x.t.q.txt == "c"