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

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

b = A("b")
l = B("l")
i = C("i")
n = D("n")
k = C("k")
h = A("h")
a = B("a")

b.o = h
l.y = h
i.w = l
n.x = a
k.w = l
h.o = b
a.y = h
assert n.x.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

b = A("b")
l = B("l")
i = C("i")
n = D("n")
k = C("k")
h = A("h")
a = B("a")

b.o = h
l.y = h
i.w = l
n.x = a
k.w = l
h.o = b
a.y = h
assert n.x.y.o.txt == "b"