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

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

e = A("e")
j = B("j")
f = A("f")
n = B("n")
l = A("l")
b = A("b")
g = B("g")

e.x = l
j.u = b
j.s = g
f.x = b
n.u = e
n.s = g
l.x = f
b.x = l
g.u = l
g.s = n
assert f.x.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

e = A("e")
j = B("j")
f = A("f")
n = B("n")
l = A("l")
b = A("b")
g = B("g")

e.x = l
j.u = b
j.s = g
f.x = b
n.u = e
n.s = g
l.x = f
b.x = l
g.u = l
g.s = n
assert f.x.x.x.x.x.x.x.txt == "b"