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

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

b = A("b")
h = B("h")
i = B("i")
d = A("d")
c = B("c")
j = B("j")
g = A("g")
m = B("m")

b.v = h
h.t = c
h.x = g
i.t = m
i.x = g
d.v = i
c.t = i
c.x = g
j.t = i
j.x = d
g.v = h
m.t = j
m.x = g
assert c.x.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

b = A("b")
h = B("h")
i = B("i")
d = A("d")
c = B("c")
j = B("j")
g = A("g")
m = B("m")

b.v = h
h.t = c
h.x = g
i.t = m
i.x = g
d.v = i
c.t = i
c.x = g
j.t = i
j.x = d
g.v = h
m.t = j
m.x = g
assert c.x.v.t.txt == "c"