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

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

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

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

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

b.u = g
g.t = n
g.r = n
e.s = m
e.y = m
m.w = l
m.r = b
m.y = h
l.t = n
l.r = g
n.t = l
n.r = g
h.s = m
h.y = m
assert h.s.y.s.w.r.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

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

b.u = g
g.t = n
g.r = n
e.s = m
e.y = m
m.w = l
m.r = b
m.y = h
l.t = n
l.r = g
n.t = l
n.r = g
h.s = m
h.y = m
assert h.s.y.s.w.r.t.t.txt == "l"