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

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

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

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

l = A("l")
c = B("c")
n = C("n")
g = D("g")
e = D("e")
m = C("m")
k = D("k")
a = A("a")

l.x = a
l.w = c
c.o = a
c.r = l
c.y = n
n.s = m
g.o = m
e.o = m
m.s = n
k.o = m
a.x = l
a.w = c
assert g.o.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.w: B = None
        self.txt = txt

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

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

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

l = A("l")
c = B("c")
n = C("n")
g = D("g")
e = D("e")
m = C("m")
k = D("k")
a = A("a")

l.x = a
l.w = c
c.o = a
c.r = l
c.y = n
n.s = m
g.o = m
e.o = m
m.s = n
k.o = m
a.x = l
a.w = c
assert g.o.s.s.s.txt == "n"