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

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

h = A("h")
c = B("c")
d = B("d")
a = A("a")
g = B("g")
i = B("i")
e = A("e")

h.s = d
h.v = a
c.x = i
c.s = e
d.x = i
d.s = h
a.s = g
a.v = h
g.x = d
g.s = e
i.x = d
i.s = e
e.s = i
e.v = h
assert i.s.s.s.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.v: A = None
        self.txt = txt

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

h = A("h")
c = B("c")
d = B("d")
a = A("a")
g = B("g")
i = B("i")
e = A("e")

h.s = d
h.v = a
c.x = i
c.s = e
d.x = i
d.s = h
a.s = g
a.v = h
g.x = d
g.s = e
i.x = d
i.s = e
e.s = i
e.v = h
assert i.s.s.s.s.x.txt == "d"