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

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

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

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

b = A("b")
a = B("a")
h = C("h")
e = D("e")
g = B("g")
k = B("k")
l = C("l")
m = D("m")

b.s = h
a.o = m
a.s = m
a.r = k
h.w = l
h.q = a
e.p = g
e.o = m
e.x = m
e.y = b
g.o = e
g.s = m
g.r = a
k.o = e
k.s = m
k.r = a
l.w = h
l.q = a
m.p = k
m.o = e
m.x = e
m.y = b
assert a.r.r.o.p.s.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

b = A("b")
a = B("a")
h = C("h")
e = D("e")
g = B("g")
k = B("k")
l = C("l")
m = D("m")

b.s = h
a.o = m
a.s = m
a.r = k
h.w = l
h.q = a
e.p = g
e.o = m
e.x = m
e.y = b
g.o = e
g.s = m
g.r = a
k.o = e
k.s = m
k.r = a
l.w = h
l.q = a
m.p = k
m.o = e
m.x = e
m.y = b
assert a.r.r.o.p.s.x.y.txt == "b"