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

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

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

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

b = A("b")
e = B("e")
d = C("d")
i = D("i")
a = A("a")
h = D("h")
g = B("g")
m = C("m")

b.y = d
b.p = d
b.r = i
b.x = e
e.r = g
e.y = m
e.o = h
d.s = e
d.q = m
d.u = m
d.o = m
i.p = a
i.t = m
i.s = d
a.y = d
a.p = d
a.r = h
a.x = g
h.p = a
h.t = d
h.s = d
g.r = e
g.y = d
g.o = i
m.s = e
m.q = d
m.u = d
m.o = d
assert b.r.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: C = None
        self.r: D = None
        self.x: B = None
        self.txt = txt

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

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

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

b = A("b")
e = B("e")
d = C("d")
i = D("i")
a = A("a")
h = D("h")
g = B("g")
m = C("m")

b.y = d
b.p = d
b.r = i
b.x = e
e.r = g
e.y = m
e.o = h
d.s = e
d.q = m
d.u = m
d.o = m
i.p = a
i.t = m
i.s = d
a.y = d
a.p = d
a.r = h
a.x = g
h.p = a
h.t = d
h.s = d
g.r = e
g.y = d
g.o = i
m.s = e
m.q = d
m.u = d
m.o = d
assert b.r.t.s.txt == "e"