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

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

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

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

l = A("l")
f = B("f")
d = C("d")
g = D("g")
h = B("h")
e = C("e")
k = B("k")
n = B("n")

l.t = e
f.x = l
f.r = g
d.w = g
d.r = e
d.s = l
d.y = f
g.s = l
h.x = l
h.r = g
e.w = g
e.r = d
e.s = l
e.y = h
k.x = l
k.r = g
n.x = l
n.r = g
assert h.x.t.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

l = A("l")
f = B("f")
d = C("d")
g = D("g")
h = B("h")
e = C("e")
k = B("k")
n = B("n")

l.t = e
f.x = l
f.r = g
d.w = g
d.r = e
d.s = l
d.y = f
g.s = l
h.x = l
h.r = g
e.w = g
e.r = d
e.s = l
e.y = h
k.x = l
k.r = g
n.x = l
n.r = g
assert h.x.t.s.t.txt == "e"