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.txt = txt

c = A("c")
l = B("l")
g = B("g")
h = B("h")
e = A("e")
i = B("i")
d = A("d")
n = B("n")
f = A("f")
k = A("k")

c.y = e
l.u = d
g.u = e
h.u = c
e.y = k
i.u = k
d.y = c
n.u = k
f.y = k
k.y = c
assert e.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.txt = txt

c = A("c")
l = B("l")
g = B("g")
h = B("h")
e = A("e")
i = B("i")
d = A("d")
n = B("n")
f = A("f")
k = A("k")

c.y = e
l.u = d
g.u = e
h.u = c
e.y = k
i.u = k
d.y = c
n.u = k
f.y = k
k.y = c
assert e.y.y.y.txt == "e"