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

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

i = A("i")
f = B("f")
m = B("m")
c = B("c")
g = B("g")
e = A("e")
b = B("b")

i.y = e
f.u = e
f.s = e
m.u = i
m.s = i
c.u = i
c.s = e
g.u = e
g.s = i
e.y = i
b.u = e
b.s = e
assert g.u.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

i = A("i")
f = B("f")
m = B("m")
c = B("c")
g = B("g")
e = A("e")
b = B("b")

i.y = e
f.u = e
f.s = e
m.u = i
m.s = i
c.u = i
c.s = e
g.u = e
g.s = i
e.y = i
b.u = e
b.s = e
assert g.u.y.y.y.y.txt == "e"