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

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

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

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

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

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

c.t = h
c.x = g
d.v = m
d.w = c
m.v = n
m.w = b
n.v = m
n.w = g
h.t = b
h.x = g
g.t = h
g.x = b
b.t = g
b.x = c
assert h.x.x.t.x.t.x.x.txt == "c"