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

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

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

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

n = A("n")
j = B("j")
c = C("c")
k = D("k")
e = C("e")
h = B("h")
b = D("b")
l = C("l")
f = C("f")

n.w = j
j.x = h
c.t = h
c.w = n
k.z = c
k.w = b
k.y = b
k.s = n
e.t = j
e.w = n
h.x = j
b.z = l
b.w = k
b.y = k
b.s = n
l.t = h
l.w = n
f.t = h
f.w = n
assert f.w.w.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

n = A("n")
j = B("j")
c = C("c")
k = D("k")
e = C("e")
h = B("h")
b = D("b")
l = C("l")
f = C("f")

n.w = j
j.x = h
c.t = h
c.w = n
k.z = c
k.w = b
k.y = b
k.s = n
e.t = j
e.w = n
h.x = j
b.z = l
b.w = k
b.y = k
b.s = n
l.t = h
l.w = n
f.t = h
f.w = n
assert f.w.w.x.x.txt == "j"