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

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

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

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

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

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

b.s = h
d.v = b
d.w = b
m.v = h
m.w = h
h.s = b
n.v = b
n.w = h
g.v = h
g.w = h
i.v = h
i.w = b
e.v = b
e.w = h
assert h.s.s.s.s.txt == "h"