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

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

a = A("a")
d = B("d")
n = B("n")
c = B("c")
l = B("l")
j = A("j")

a.o = j
a.w = j
d.u = a
d.y = j
n.u = j
n.y = j
c.u = j
c.y = j
l.u = j
l.y = a
j.o = a
j.w = a
assert c.y.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.w: A = None
        self.txt = txt

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

a = A("a")
d = B("d")
n = B("n")
c = B("c")
l = B("l")
j = A("j")

a.o = j
a.w = j
d.u = a
d.y = j
n.u = j
n.y = j
c.u = j
c.y = j
l.u = j
l.y = a
j.o = a
j.w = a
assert c.y.o.o.o.txt == "a"