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

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

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

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

b = A("b")
h = B("h")
f = C("f")
e = D("e")
n = C("n")
m = A("m")
d = C("d")
a = D("a")
c = A("c")

b.s = e
h.w = c
h.y = c
f.p = e
e.u = d
e.x = a
n.p = e
m.s = a
d.p = a
a.u = d
a.x = e
c.s = a
assert a.u.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

b = A("b")
h = B("h")
f = C("f")
e = D("e")
n = C("n")
m = A("m")
d = C("d")
a = D("a")
c = A("c")

b.s = e
h.w = c
h.y = c
f.p = e
e.u = d
e.x = a
n.p = e
m.s = a
d.p = a
a.u = d
a.x = e
c.s = a
assert a.u.p.u.txt == "d"