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

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

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

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

l = A("l")
i = B("i")
e = C("e")
k = D("k")
h = D("h")
c = A("c")
a = B("a")
d = B("d")

l.x = e
l.q = k
l.o = i
i.w = e
i.s = l
i.o = c
e.p = l
k.p = h
k.s = a
h.p = k
h.s = a
c.x = e
c.q = h
c.o = i
a.w = e
a.s = l
a.o = c
d.w = e
d.s = l
d.o = c
assert a.s.q.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.q: D = None
        self.o: B = None
        self.txt = txt

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

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

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

l = A("l")
i = B("i")
e = C("e")
k = D("k")
h = D("h")
c = A("c")
a = B("a")
d = B("d")

l.x = e
l.q = k
l.o = i
i.w = e
i.s = l
i.o = c
e.p = l
k.p = h
k.s = a
h.p = k
h.s = a
c.x = e
c.q = h
c.o = i
a.w = e
a.s = l
a.o = c
d.w = e
d.s = l
d.o = c
assert a.s.q.p.p.txt == "k"