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

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

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

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

l = A("l")
e = B("e")
j = C("j")
i = D("i")
m = C("m")
g = A("g")

l.r = e
l.s = e
l.y = e
l.w = m
e.r = m
j.t = e
j.o = i
j.q = i
i.r = e
i.x = e
m.t = e
m.o = i
m.q = i
g.r = e
g.s = e
g.y = e
g.w = m
assert e.r.q.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: B = None
        self.w: C = None
        self.y: B = None
        self.txt = txt

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

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

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

l = A("l")
e = B("e")
j = C("j")
i = D("i")
m = C("m")
g = A("g")

l.r = e
l.s = e
l.y = e
l.w = m
e.r = m
j.t = e
j.o = i
j.q = i
i.r = e
i.x = e
m.t = e
m.o = i
m.q = i
g.r = e
g.s = e
g.y = e
g.w = m
assert e.r.q.x.r.txt == "m"