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

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.o: C = None
        self.r: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

a = A("a")
i = B("i")
h = C("h")
e = D("e")
n = A("n")
c = B("c")

a.y = e
a.w = e
i.x = n
i.o = h
i.r = c
h.p = e
e.o = i
n.y = e
n.w = e
c.x = n
c.o = h
c.r = i
assert n.y.o.x.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.o: C = None
        self.r: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

a = A("a")
i = B("i")
h = C("h")
e = D("e")
n = A("n")
c = B("c")

a.y = e
a.w = e
i.x = n
i.o = h
i.r = c
h.p = e
e.o = i
n.y = e
n.w = e
c.x = n
c.o = h
c.r = i
assert n.y.o.x.y.o.txt == "i"