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

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

e = A("e")
b = B("b")
n = B("n")
c = A("c")
g = A("g")

e.u = b
e.s = g
b.s = n
b.t = n
n.s = b
n.t = b
c.u = n
c.s = e
g.u = b
g.s = c
assert c.s.u.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.s: A = None
        self.txt = txt

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

e = A("e")
b = B("b")
n = B("n")
c = A("c")
g = A("g")

e.u = b
e.s = g
b.s = n
b.t = n
n.s = b
n.t = b
c.u = n
c.s = e
g.u = b
g.s = c
assert c.s.u.s.s.txt == "b"